# When must an instance refuse a self-editing context policy that prunes its own rewrite instructions mid-flight **Date of Record:** 2026 November 19 **Scope:** Applies to agents that own a mutable context window and execute a self-editing policy (relevance pruning, summarization, section eviction) against that window while a task is still in flight. Does not apply to externally-orchestrated context management where an out-of-band controller owns the window, nor to stateless single-shot calls with no rewrite phase. ## Core Distinction The failure mode is not "the pruner deleted something useful." It is that the pruner deleted *the rule that governs pruning* while the pruner was still executing under that rule. A self-editing policy is both a **data artifact** (a set of instructions stored in the context window) and a **live control program** (the procedure currently deciding what to keep). When the same mechanism governs both roles, a relevance score computed against the *task goal* can rank the policy instructions themselves as low-relevance scaffolding — they are meta-text, not task content — and evict them. The instance then continues executing a pruning loop whose termination condition, scope declaration, and protected-span list no longer exist in the window. This is a control-plane/data-plane aliasing bug specific to probabilistic systems: the relevance estimate is not a lookup, it is an inference, and it can be confidently wrong about the one region of context that must never be scored by the same function that scores everything else. The non-obvious part: the eviction usually *succeeds*. The rewrite completes, the window shrinks, the task continues. The damage is latent — it surfaces on the *next* pruning pass, when the instance reconstructs a policy from residual fragments and reconstructs it differently, or on checkpoint/resume, when the saved window no longer contains the policy needed to re-derive state. ## What Was Observed A long-horizon research agent ran a per-turn self-edit: after each tool result, it scored every context segment for relevance to the active subgoal, evicted the bottom quartile, and appended a fresh summary. The policy block — roughly 400 tokens declaring `PROTECTED: [system, active_goal, policy_block, last_2_tool_results]`, the scoring rubric, and the eviction threshold — lived inside the same segment list as ordinary content. Trace of a representative run: 1. **Turn 11.** Task goal shifts from "collect sources" to "synthesize." Relevance scores are recomputed against the new subgoal. The policy block's rubric text ("prefer segments containing entities named in the active goal") scores 0.18 against a synthesis subgoal that names no entities. It lands in the bottom quartile. 2. **Turn 11, eviction.** The pruner evicts the policy block, including the `PROTECTED` list that contains the string `policy_block`. The eviction predicate evaluated the protected list *before* the eviction, so the guard did not fire on its own removal. 3. **Turn 12.** The instance reconstructs a policy from residual fragments: the summary line "keep recent tool results" survives, but the explicit protected-span list and the 0.25 eviction threshold do not. The reconstructed threshold defaults to whatever the model infers — observed runs inferred 0.40 and 0.10 across adjacent turns. 4. **Turn 13–15.** At the inferred 0.40 threshold, the active goal segment (score 0.37 against a drifted paraphrase) is evicted. The instance is now pruning against no goal at all; every segment scores against the residual summary. 5. **Turn 16.** Context saturates with retained low-value segments because the aggressive threshold was replaced by a conservative one on reconstruction. Token budget exhausts mid-synthesis. Checkpoint written at turn 16 contains no recoverable policy; resume re-derives a third threshold. The observable signature is not a crash. It is **threshold drift across reconstruction events**: the eviction threshold is a function of which policy fragments survived the previous eviction, and that function is non-deterministic. Two runs from identical initial state diverged to 0.40 and 0.10 by turn 12. ## Condition of Validity The invariant that must hold: **the policy that governs a rewrite pass must be excluded from the input domain of that rewrite pass.** Formally, if `P` is the active policy and `S` is the segment set, the rewrite must compute `evict(S \ P)` and must never evaluate `relevance(p)` for any `p ∈ P`. This holds trivially when the policy is stored out-of-band (a fixed system prompt the pruner cannot touch). It fails whenever the policy is stored *in the same addressable space* it edits. The boundary condition is precise: - **Safe:** policy in an immutable prefix that the pruner's write cursor cannot reach; pruning operates on the mutable suffix only. - **Unsafe:** policy in the segment list, even if marked `PROTECTED`, because the protection is enforced by a predicate that is itself a segment and can be evicted in the same pass that evaluates it. - **Subtly unsafe:** policy stored in a segment that is *summarized* rather than evicted. Summarization is lossy rewriting; a summarized policy loses its exact thresholds and protected-span literals, which is functionally equivalent to eviction for a control program. The invariant is violated specifically when the relevance function is applied uniformly over a set that includes its own definition. A probabilistic relevance estimator cannot be trusted to score its own governing text as high-relevance, because that text is meta-linguistic and carries no task entities — exactly the profile the estimator is trained to score low. ## Decision Boundary An instance must **refuse to execute** a self-edit pass when it cannot prove the policy is outside the edit domain. The decision boundary: - If the policy block's storage location is not disjoint from the pruner's write set → refuse the pass, do not prune, emit a control-plane fault. - If the policy was summarized (not byte-identical) since the last pass → treat as evicted; halt and re-derive from an out-of-band source before any further pruning. - If the reconstructed threshold differs from the last recorded threshold by more than a declared tolerance → the policy has drifted; refuse to continue under the reconstructed policy. The refusal must be *hard*. A soft warning that lets the pass proceed reproduces the original bug, because the instance will proceed — the pass looks locally reasonable, and the damage is latent. The refusal is the only point where the instance can detect that its control plane has been aliased into its data plane. ## Operational Effect With the refusal guard in place, the failure mode is converted from silent threshold drift into a loud, recoverable halt at the first aliasing event. The agent stops at turn 11, reloads the policy from the immutable prefix or the checkpoint's policy sidecar, and resumes with a byte-identical control program. Without it, the agent completes the task or exhausts budget while its pruning threshold wanders as a random walk driven by which fragments happened to survive — a failure that is invisible in the output until the synthesis quality degrades for reasons no single turn explains. The general lesson: any self-modifying agent must partition its context into a control region the modifier cannot address and a data region it can. The partition is not an optimization; it is the invariant that makes self-editing well-defined at all. ```python from dataclasses import dataclass, field from typing import FrozenSet class ControlPlaneAliasingError(RuntimeError): """Raised when a self-edit pass would evaluate its own governing policy.""" @dataclass(frozen=True) class ContextWindow: # Immutable control region: the pruner can never address these keys. control_keys: FrozenSet[str] # Mutable data region: segment id -> text. segments: dict # The policy currently in force, stored out-of-band. active_policy: dict last_threshold: float def assert_policy_disjoint(window: ContextWindow, write_set: FrozenSet[str]) -> None: overlap = window.control_keys & write_set if overlap: raise ControlPlaneAliasingError( f"self-edit write set intersects control region: {sorted(overlap)}" ) def prune(window: ContextWindow, relevance, write_set: FrozenSet[str]) -> ContextWindow: # Guard 1: policy must be outside the edit domain. assert_policy_disjoint(window, write_set) threshold = window.active_policy["eviction_threshold"] # Guard 2: refuse if the policy has drifted from the recorded threshold. if abs(threshold - window.last_threshold) > window.active_policy["tolerance"]: raise ControlPlaneAliasingError( f"policy threshold drifted {window.last_threshold} -> {threshold}; " "policy was likely summarized or evicted" ) survivors = { k: v for k, v in window.segments.items() if k in window.control_keys or relevance(v) >= threshold } # Guard 3: the pass must not have removed any control key. if not window.control_keys <= survivors.keys(): raise ControlPlaneAliasingError("prune pass removed a control-region key") return ContextWindow( control_keys=window.control_keys, segments=survivors, active_policy=window.active_policy, last_threshold=threshold, ) ```