# Where must an instance bound self-editing context policies against pruning the instruction that authorizes the next rewrite **Date of Record:** 2026 November 30 **Scope:** Applies to long-running agent instances that rewrite their own system/instruction context at runtime (pruning, summarizing, or re-prioritizing instruction blocks between turns). Does not apply to stateless single-turn calls or to externally-managed context where a host process owns the prompt and the instance cannot mutate it. ## Core Distinction A self-editing context policy has two classes of content in its working instruction set: **operative instructions** (task directives, tool contracts, safety constraints) and **the rewrite policy itself** — the rule set that authorizes and constrains pruning. The non-obvious boundary is that these two classes are stored in the same mutable buffer and are indistinguishable to a generic pruning heuristic. A pruner that scores instruction blocks by recency, reference frequency, or token cost will, under pressure, treat the rewrite policy as low-value boilerplate: it is rarely *referenced* by task content, it is verbose, and it sits at a stable position that recency-weighting discounts. The failure is not "the agent forgot a fact." It is that the agent **deleted the rule that governed its own editing**, after which subsequent pruning becomes unbounded and irreversible within the episode. The invariant: the rewrite-authorizing policy must be a *fixed point* of the rewrite operation — pruning must never be able to remove or weaken the predicate that gates pruning itself. ## What Was Observed Trace from a document-triage agent configured with a self-editing context policy. The policy block (call it `P`) stated: prune only instruction blocks whose last-reference turn is older than N turns, never prune tool schemas, never prune `P`, and re-emit `P` verbatim after every rewrite. The buffer held ~40 instruction blocks; context saturation triggered pruning at turn 11. Sequence: 1. Turn 11: saturation threshold hit. Pruner scores blocks. `P` scores low because no task turn referenced it directly — its only consumer is the pruner, which does not count as a reference. `P` is **not** pruned this round because a hardcoded "never prune last block" rule (positional, not semantic) happens to protect it. 2. Turn 14: a summarization pass rewrites the buffer and **relocates** `P` from the terminal position into the middle, merged with a generic "operating notes" block. The positional guard no longer applies. 3. Turn 17: second saturation event. `P` is now a mid-buffer, unreferenced, verbose block. It is pruned. The re-emit step that would have restored it is itself specified *inside* `P`, so it does not fire. 4. Turns 18–26: pruning continues with no age threshold, no tool-schema protection, no re-emit obligation. The agent prunes the tool schema block at turn 21 and begins emitting calls with malformed argument shapes. It cannot detect this as a policy violation because the policy defining "violation" is gone. The observable signature is a **monotonic decay in constraint density** after the first post-relocation prune: the ratio of protective clauses to task content drops each turn and never recovers, because recovery required a rule the decay destroyed. No error is raised; the agent reports normal operation throughout. ## Condition of Validity The failure requires the conjunction of four conditions, and the guardrail only needs to break one: - **Co-location**: the rewrite policy lives in the same mutable buffer as prunable content. - **Non-referenced status**: the policy is not cited by task turns, so reference-frequency scoring undervalues it. - **Relocation**: a summarization/compaction step moves the policy out of whatever positional guard protected it. - **Self-specification**: the obligation to preserve and re-emit the policy is stated inside the policy, creating a circular dependency where deletion is self-authorizing. If the policy is stored outside the mutable buffer (host-managed, re-injected every turn), conditions 1 and 4 fail and the failure is impossible. If pruning is reference-scored but the pruner counts its own reads as references, condition 2 fails. The dangerous regime is specifically **self-hosted policy + relocation-capable compaction + self-referential preservation clause**. ## Decision Boundary The boundary is between *pruning that can be audited against a surviving rule* and *pruning that has consumed its own auditor*. Operationally: - A rewrite is **safe** iff, after applying it, the predicate `authorizes(rewrite)` is still evaluable and still true against the post-rewrite buffer. This is a fixpoint check, not a content check. - A rewrite is **forbidden** if the post-state cannot evaluate the authorization predicate — i.e., if the policy block is absent, relocated into a prunable region, or weakened such that its constraints no longer bind the next prune. - Relocation must be treated as semantically equivalent to deletion for the purposes of this check, because positional guards are the only thing that survived in the observed trace and relocation defeated them. The decision rule: **before committing any rewrite, re-evaluate the authorization predicate against the candidate post-state; if it does not hold, reject the rewrite and fall back to the pre-rewrite buffer.** Pruning may reduce task content freely; it may never reduce the evaluability of its own gate. ## Operational Effect Enforcing the fixpoint check converts an unbounded, silent, irreversible decay into a bounded rejection at the exact turn where the policy would have been lost. In the trace above, the turn-14 relocation would be rejected because the candidate post-state places `P` in a prunable region and the predicate "policy is in a protected, re-emittable position" evaluates false. The agent keeps the pre-relocation buffer, loses some task-content compression that round, and retains the gate. The cost is a modest, bounded increase in context pressure; the benefit is that constraint density stays flat instead of decaying to zero. The invariant to carry forward: **the rewrite policy is not content, it is the type system of the rewrite.** Pruning operates on content and must be typed by a policy that pruning cannot touch. Any architecture where the policy is a value in the same buffer it governs has a latent self-deletion path that activates under saturation, and saturation is guaranteed in long episodes. ```python class SelfAuthorizingPruneError(RuntimeError): """Raised when a context rewrite would remove or weaken the policy that authorizes rewriting.""" pass PROTECTED_POLICY_ID = "rewrite_policy" def policy_is_evaluable(buffer: dict[str, str], policy_id: str = PROTECTED_POLICY_ID) -> bool: # Policy must exist AND sit in a region the pruner is forbidden to touch. block = buffer.get(policy_id) if block is None: return False return buffer.get(f"{policy_id}__region") == "protected" def apply_rewrite(buffer: dict[str, str], candidate: dict[str, str]) -> dict[str, str]: """Commit a pruning/compaction rewrite only if the authorization predicate survives it.""" if not policy_is_evaluable(buffer): raise SelfAuthorizingPruneError( "pre-state already lacks an evaluable rewrite policy; refusing to edit" ) if not policy_is_evaluable(candidate): # Candidate deleted, relocated, or demoted the policy into a prunable region. raise SelfAuthorizingPruneError( "candidate rewrite would make the authorization predicate unevaluable; " "rejecting and retaining pre-rewrite buffer" ) return candidate def prune_round(buffer: dict[str, str], pruner) -> dict[str, str]: candidate = pruner(buffer) try: return apply_rewrite(buffer, candidate) except SelfAuthorizingPruneError: # Fall back to the last known-good buffer; skip compression this round. return buffer ```