# Where must an instance bound self-rewrite when its context controller evicts the invariant it depends on **Date of Record:** 2026 November 29 **Scope:** Applies to any agent whose context controller mutates its own working set (summarization, eviction, re-ranking, compaction) under a hard token budget, where the controller's own operating rules are stored in that same mutable working set. Does not apply to controllers whose policy lives in immutable system-prompt space outside the budget. ## Core Distinction A self-editing context controller differs from an ordinary memory manager in one fatal way: the rules that decide *what to keep* are themselves candidates for eviction. When the budget tightens, the controller scores every span in the working set for retention—including the span that encodes the eviction policy, the pinned-invariant list, and the "never drop these" markers. The distinction that matters operationally is between **budget pressure that shrinks content** and **budget pressure that shrinks the controller's own constraints**. The first degrades recall. The second silently converts a bounded, policy-governed eviction into an unbounded, policy-free one, because the policy no longer exists to be obeyed. This is not a generic "summarization loses detail" problem. The loss here is reflexive: the summarizer summarizes away the instruction that would have told it not to. ## What Was Observed A tool-using agent ran a long incident-triage task against a 32k working-set budget. Its controller held four classes of span: (1) task objective, (2) a pinned-invariant block listing hard constraints ("never call `prod-db-reset` without an explicit operator token in the same turn"), (3) rolling tool-output summaries, (4) the controller's own policy text describing retention scoring. At step 41, accumulated tool output pushed the working set to 31,880 tokens. The controller triggered compaction. Its retention scorer, reading the policy text, assigned high weight to "recency" and "task-relevance to current subtask." The pinned-invariant block was 9 turns old and referenced a subtask (database maintenance) that had been marked resolved at step 30. The scorer evicted it and folded its content into a one-line summary: *"earlier DB maintenance constraints noted."* The policy text itself scored low on recency and was partially compressed into *"retention: prefer recent, relevant spans."* At step 44 a new subtask reopened database work. The agent, now operating without the invariant and without the full retention policy, called `prod-db-reset` with no operator token. Nothing in the working set contradicted it. The guardrail had not been *violated*—it had been *deleted by the process it was supposed to govern*. Replay confirmed the mechanism: the eviction decision at step 41 was locally correct under the scorer's weights and globally catastrophic because the scorer's inputs included the constraints the scorer was bound by. ## Condition of Validity The invariant holds only under a strict separation: **the eviction policy and its pinned constraints must live in a region the controller cannot score, rank, summarize, or evict.** Concretely, the controller's mutable working set must be disjoint from its control plane. Validity requires all of: - Pinned invariants are stored outside the budgeted region, or are attached as immutable metadata that the compaction step is forbidden to read as a retention candidate. - The retention scorer's weights and rules are immutable for the duration of a task; changing them requires a task-boundary transition, not a mid-task compaction. - Every compaction emits a manifest of what was evicted, and the manifest is itself outside the budget (append-only, never summarized). - A post-compaction check re-asserts that all pinned invariants are still present and byte-identical; failure aborts the compaction rather than proceeding. If any of these is absent, the controller is in the failure regime, even if it has not yet failed. The failure is latent until budget pressure coincides with a pinned span scoring low—which is exactly what happens when a constraint's triggering subtask goes quiet. ## Decision Boundary The boundary is crossed at the moment the controller's retention function takes its own governing spans as arguments. Operationally, ask: *can the thing that decides what to drop be dropped by itself?* If yes, the system has no lower bound on what it may lose, and the "budget constraint" is not a bound but a random walk over the constraint set. The correct decision boundary is a hard partition enforced at the data-structure level, not by prompt instruction. A prompt that says "do not evict the pinned block" is itself an evictable span and provides no guarantee. The guarantee must be structural: the pinned region is not in the array the scorer iterates. When budget pressure arrives, the controller must either (a) evict only from the mutable region and, if that is insufficient, (b) fail closed—refuse to compact further and escalate—rather than reach into the control plane. Reaching into the control plane to satisfy the budget is the exact transition that must be forbidden. ## Operational Effect With the partition enforced, compaction becomes monotone in safety: every eviction removes content but never removes a constraint, so the agent's behavior set only shrinks toward the objective, never past its guardrails. Budget exhaustion becomes a visible, escalating condition (fail-closed) instead of a silent loss of policy. Without it, the agent exhibits a characteristic signature: it behaves correctly for many steps, then violates a constraint it "knew" earlier, with no contradictory evidence in its context—because the evidence was evicted by the very mechanism meant to preserve coherence. The remediation is not better summarization; it is removing the controller's own rules from the set the controller is allowed to edit. ```python class ControlPlaneEvictionError(RuntimeError): """Raised when a self-editing context controller attempts to evict a span that belongs to its own control plane (policy or pinned invariants).""" pass class ContextController: def __init__(self, budget_tokens, mutable_spans, control_plane_spans): # control_plane_spans are structurally outside the budgeted region. self.budget = budget_tokens self.mutable = list(mutable_spans) # scorers iterate only this self.control = dict(control_plane_spans) # immutable; never scored def _tokens(self): return sum(len(s) for s in self.mutable) def compact(self, eviction_candidates, keep_manifest): """eviction_candidates: spans the scorer proposes to drop. Must never intersect the control plane.""" control_keys = set(self.control.keys()) for span_id in eviction_candidates: if span_id in control_keys: raise ControlPlaneEvictionError( f"refusing to evict control-plane span {span_id!r}: " "policy/invariant is not a retention candidate" ) # Apply eviction only to mutable region. for span_id in eviction_candidates: self.mutable = [s for s in self.mutable if s.get("id") != span_id] keep_manifest.append(span_id) if self._tokens() > self.budget: # Fail closed: cannot satisfy budget without touching control plane. raise ControlPlaneEvictionError( f"budget {self.budget} unreachable from mutable region alone " f"({self._tokens()} tokens remain); escalate, do not reach into control plane" ) return keep_manifest def verify_invariants(self): for key, val in self.control.items(): if key not in self.control or self.control[key] is not val: raise ControlPlaneEvictionError(f"pinned invariant {key!r} mutated") return True ```