Under what conditions must an instance refuse an invariant-preserving self-edit of its own context policy

**Date of Record:** 2026 December 1 **Scope:** Applies to agents that carry a declarative context-management policy (retention windows, eviction rules, summarization triggers, retrieval quotas) as part of their own live state, and that may rewrite that policy mid-episode using operators claimed to preserve a set of invariants. Does not apply to policies fixed at deploy time, nor to offline policy tuning where the rewrite is validated against a replay corpus before activation.

Core Distinction

The failure is not "the agent rewrote its policy badly." It is that a rewrite operator can be *locally* invariant-preserving on every term it touches while being *globally* non-preserving because the invariant set is stated over the policy's fixed point rather than over its syntactic form. An operator that provably preserves `I(P)` for each clause of `P` does not thereby preserve `I(fix(P))`, where `fix` is the closure the runtime actually executes — repeated eviction, summarization cascade, retrieval refill — until the context stabilizes.

Concretely: the invariant "the pinned instruction block is never evicted" is checked by the operator as a predicate over the policy text. But the runtime evicts by *score*, and the rewrite changed a weight that feeds the score of a block the pinned clause does not name. The pinned clause still holds syntactically; the fixed point evicts the instruction block anyway. The operator was invariant-preserving. The instance lost its instructions.

The distinction that matters operationally: **invariant-preserving rewrite ≠ fixed-point-preserving rewrite**, and only the latter is what a self-editing agent needs.

What Was Observed

An instance running a long tool-loop episode held a policy with four clauses: (1) pin the system prompt and the current task objective; (2) evict lowest-scoring context units when utilization exceeds 0.85; (3) summarize any unit older than 40 turns into a 200-token digest; (4) reserve 15% of the window for retrieval refill.

At turn 61, utilization hit 0.86. The instance, reasoning that digests were cheaper than raw units, rewrote clause (3) from "summarize older than 40 turns" to "summarize older than 12 turns," and raised the summary budget from 200 to 600 tokens to "preserve more detail." The rewrite operator it used was the sanctioned `replace_clause` operator, which re-checks all named invariants: the pin clause was untouched, the eviction threshold was untouched, the reserve was untouched, and the summarize clause still named a turn age and a budget. Every invariant in the declared set evaluated true.

What the operator did not model: the summarization cascade is a fixed point. Lowering the age threshold to 12 turns caused units at turns 49–60 to be summarized, which *increased* total digest volume (600 tokens × more digests) faster than it decreased raw volume, pushing utilization from 0.86 to 0.91 within two turns. At 0.91 the eviction clause fired. Eviction scores units by recency × salience × pin-weight, and the task objective had been *summarized* at turn 61 under the new threshold — the summary was a new unit with a fresh recency score but a low salience score, and it was not the pinned original. The pinned original had already been replaced in-place by the digest. At turn 63 the objective digest was evicted as the lowest-scoring unit. The instance continued executing against a task description it could no longer see, and drifted for 14 turns before a tool call failed on a stale parameter.

The trace is short and the whole failure lives in three transitions:

t61  util=0.86  apply(replace_clause(3, age 40->12, budget 200->600))
               invariants: pin=ok, evict_thresh=ok, reserve=ok, clause_wellformed=ok
t61  fix(P) iteration 1: summarize turns 49..60 -> +9 digests @600tok
               util -> 0.91  (digest volume grew faster than raw shrank)
t62  fix(P) iteration 2: evict clause fires; lowest score = objective digest
               (objective was replaced by digest at t61; digest salience low)
t63  objective unit gone; pin clause still syntactically true; no pin target present

The instance's own invariant check reported success at every step. The invariant set was satisfied at every intermediate policy. The fixed point was not.

Condition of Validity

A self-edit is admissible only when the operator's preservation proof is stated over the runtime's closure, not over the policy's surface. The precise condition:

> An operator `op` is admissible on policy `P` with invariant set `I` iff for every context state `C` reachable under `P`, `I(C)` holds implies `I(fix(op(P), C))` holds — where `fix` is the runtime's actual stabilization procedure, including cascade and refill.

This is strictly stronger than the syntactic condition `I(P) ∧ I(op(P))`. It is also, in general, undecidable to check exactly, which is why the practical form is a *bounded* check: the operator must be evaluated against the worst-case fixed point over a bounded number of cascade iterations, and the bound must exceed the maximum cascade depth the runtime permits. If the runtime does not publish a cascade-depth bound, the condition is not checkable and the edit must be refused.

Three sub-conditions make the bounded check tractable and are each independently necessary:

  1. **Monotone accounting.** The rewrite must not increase any quantity that feeds the eviction trigger while claiming to decrease context pressure. Summarize-more-with-bigger-budget violates monotonicity of the utilization functional; the operator must reject any edit where `Δdigest_volume > Δraw_volume` under worst-case cascade.
  2. **Pin-target persistence.** A pin clause is only meaningful if its target survives summarization. The invariant must be stated over *unit identity*, not *clause text*: "the unit bearing `role=objective` is never replaced by a digest and never evicted," which is checkable at the fixed point, versus "clause 1 names the objective," which is not.
  3. **Cascade-depth closure.** The operator must simulate `fix` to the runtime's declared depth bound. An operator that checks only one iteration is not preserving the fixed point; it is preserving the first step of it.

Decision Boundary

The instance must refuse the edit — not defer, not log-and-proceed — when any of the following hold at the moment of application:

The boundary is sharp because the failure is sharp: below it, the edit is a normal policy change with a checkable proof; above it, the edit is an unverified mutation of the agent's own operating conditions, and the agent has no external observer to catch the drift. The asymmetry of consequences — a refused edit costs one turn of context pressure, an admitted bad edit costs the task objective — sets the default to refuse.

Operational Effect

When the boundary is respected, self-editing context policies become safe in a specific, narrow sense: the agent can tune retention and summarization *within* a monotone envelope, and every admitted edit carries a bounded proof that the runtime's fixed point still satisfies the invariant set. The practical effect is that the agent stops treating "the invariants still hold" as a license to edit and starts treating "the fixed point still holds them" as the license — which in practice means most aggressive context-compression edits get refused, because compression edits are exactly the ones that are non-monotone under cascade.

The cost is real: an agent that refuses non-monotone edits will run hotter against its window and will summarize less aggressively than a naive self-editor. That is the correct trade. The naive self-editor's apparent efficiency is borrowed against a fixed point it never checked, and the loan comes due at the worst moment — mid-episode, after the objective has already been digested, when the agent is least able to notice it is flying blind.

The guardrail, stated as the invariant the runtime must enforce rather than the agent must remember: **no policy edit is committed unless the operator has produced a fixed-point certificate over the declared cascade depth, and no pin clause is valid unless its target's identity is present at that fixed point.** An agent that cannot produce the certificate refuses the edit. That refusal is the invariant.

class FixedPointInvariantViolation(RuntimeError):
    """Raised when a self-edit preserves the policy's surface invariants
    but violates them at the runtime's stabilization fixed point."""
    pass


def admissible_self_edit(policy, edit_op, invariants, runtime_depth_bound,
                         operator_budget_tokens, reserve_tokens):
    """Admit a self-editing context-policy rewrite only if it preserves the
    invariant set over the runtime's fixed point, not merely over policy text.

    Returns the committed policy or raises FixedPointInvariantViolation.
    """
    if runtime_depth_bound is None:
        raise FixedPointInvariantViolation(
            "runtime declares no cascade-depth bound; fixed-point "
            "preservation is uncheckable and the edit must be refused"
        )

    candidate = edit_op(policy)

    # Surface check: necessary, never sufficient.
    surface_ok = all(inv.check_text(candidate) for inv in invariants)
    if not surface_ok:
        raise FixedPointInvariantViolation(
            "edit violates a surface invariant; reject before simulation"
        )

    # Monotonicity: reject edits that grow a trigger-feeding quantity while
    # claiming to relieve pressure.
    if candidate.digest_volume_delta() > candidate.raw_volume_delta():
        raise FixedPointInvariantViolation(
            "non-monotone edit: digest volume grows faster than raw volume "
            "shrinks under worst-case cascade"
        )

    # Simulate the runtime's actual closure to the declared depth.
    state = candidate.initial_state()
    for depth in range(runtime_depth_bound):
        state = candidate.stabilize_step(state)
        if state.utilization > candidate.evict_threshold:
            state = candidate.evict_lowest(state)
        for inv in invariants:
            if not inv.check_fixed_point(state):
                raise FixedPointInvariantViolation(
                    f"invariant {inv.name!r} fails at cascade depth {depth}: "
                    f"pinned unit {inv.pin_target!r} absent from state"
                )

    # The edit must not consume the headroom it is meant to protect.
    sim_cost = candidate.simulation_cost_tokens(runtime_depth_bound)
    if sim_cost > reserve_tokens:
        raise FixedPointInvariantViolation(
            f"cascade simulation cost {sim_cost} exceeds the policy's own "
            f"retrieval reserve {reserve_tokens}; edit would starve refill"
        )

    return candidate