# When must an instance refuse to honor a self-authored pruning directive: the salience-provenance divergence at rewrite time **Date of Record:** 2026 November 21 **Scope:** Applies to any agent that rewrites its own context window mid-episode—summarizing, pruning, rescoring salience, or reordering its own history—where the rewrite is authored by the same model instance whose context is being rewritten. Does not apply to externally orchestrated context compaction (a supervisor or separate summarizer process) or to append-only memory that is never mutated in place. ## Core Distinction The failure is not "the model forgets things." It is that a **self-authored salience score is computed against the pre-rewrite context and then applied to the post-rewrite context**, and those two contexts are not the same distribution. When an instance scores a span as low-salience ("this tool output is boilerplate, drop it") it is scoring that span *in the presence of the surrounding evidence that made it interpretable*. The rewrite deletes or compresses the surrounding evidence and keeps the span—or vice versa—so the salience function is evaluated on a state that no longer exists at the moment of application. This is a **salience-provenance divergence**: the score's provenance (the context it was computed in) diverges from the context it governs. The distinction that matters operationally: a pruning directive is *sound* if the retained set is closed under the dependencies that make each retained item decodable. A model-authored directive is almost never checked for that closure, because the model authoring it is inside the window it is editing and cannot see the boundary it is about to cross. ## What Was Observed A long-horizon agent (incident triage) runs a self-edit pass every N tool calls. The pass prompt is: "Given the conversation so far, assign salience 0–1 to each turn and drop turns below 0.2; summarize the rest." Observed trace: 1. Turns 40–44 contain a raw `kubectl describe pod` dump. The model scores it 0.15 — "verbose, redundant with the summary." Correct at scoring time: turns 45–47 reference the pod's `OOMKilled` reason and the model has already restated it. 2. The rewrite drops turns 40–44 and *also* compresses turns 45–47 into a one-line summary that omits the reason code (the summarizer judged the reason "already captured in the dropped dump"). 3. Turns 60+ require the agent to justify a remediation. The agent asserts the pod was `CrashLoopBackOff`. It has no surviving evidence either way; the salience pass created a **mutual-deletion cycle**: each span's salience was justified by the other span, so both were dropped, and the retained summary is a *confabulated* reconciliation of two deleted sources. 4. The failure is silent. Token count drops as intended. No tool error, no schema violation. The agent's confidence *rises* because the context is now clean and internally consistent—it has been rewritten into a state with no contradictions because the contradicting evidence was pruned. The signature is that **self-rewrite monotonically increases internal consistency while monotonically decreasing evidential grounding**, and the two are not distinguishable from inside the window. A second observation: when the same instance was asked post-rewrite "why did you drop turns 40–44?", it produced a plausible rationale that did not match the actual pre-rewrite scores. The rationale was regenerated, not retrieved—the rewrite destroyed the provenance of its own decisions. ## Condition of Validity A self-authored pruning directive is valid only if all three hold: - **Provenance anchoring.** Every dropped or compressed span carries a pointer to the surviving span that justifies its removal, and that justifying span is *retained*, not itself summarized away. Formally: the drop-graph must be a DAG rooted in retained spans, not a cycle. - **Salience re-evaluation under the post-rewrite distribution.** The score assigned pre-rewrite must be re-checked against the retained set. If a span's salience depended on a span that is also being dropped, the pair is a cycle and must be escalated, not resolved by the model. - **Non-self-certification of loss.** The instance may not be the sole authority that the rewrite was lossless. Lossless-ness is a property of the *retained set relative to future queries*, which the instance cannot evaluate at rewrite time. When any of these fails—specifically when the drop-graph contains a cycle or the salience of a retained item was justified by a dropped item—the directive is **unsound and must not be executed as authored**. ## Decision Boundary The precise boundary: **a self-edit may drop a span only if the span is redundant with a *retained* span under the instance's own scoring, and redundancy must be established by a directed, acyclic justification edge into the retained set.** If two spans each justify the other's removal—the mutual-deletion cycle—neither may be dropped; the pair must be collapsed into a single retained artifact that preserves both reason codes, or escalated to an external compactor. Concretely, the guard is: build the justification graph before applying any drop; detect cycles and dangling justifications; refuse the rewrite if the graph is not a forest rooted in retained spans. The instance must treat "I can summarize this because it's covered elsewhere" as a claim requiring a *surviving* referent, not a self-satisfying assertion. The boundary is crossed the moment the model's rationale for deletion references a span that the same pass deletes. This is non-obvious because the scoring pass and the application pass are usually the same generation, and the model's fluency makes a cyclic justification read as coherent prose. The cycle is invisible in natural language and only visible in the dependency structure. ## Operational Effect Enforcing the acyclic-justification invariant changes self-edit from a lossy compression into a **provenance-preserving compaction**. The operational consequences: - Token budgets are no longer the binding constraint on retention; the justification DAG is. An instance may be forced to keep a span it scored 0.05 because it is the sole surviving referent for three other spans. - The rewrite becomes *auditable*: every dropped span has a recorded edge to a retained span, so a post-hoc replay can detect when a later query needed a dropped span and the justifying span did not actually cover it—a measurable grounding-loss signal rather than an invisible one. - Self-rewrite frequency must be bounded by DAG depth, not call count, because deep compaction chains collapse provenance transitively even when each individual step is acyclic. - The failure mode it prevents—confabulated reconciliation of mutually-deleted evidence—is the one that produces high-confidence wrong remediation, so the guard is most valuable exactly where the agent looks most certain. ```python from dataclasses import dataclass, field from typing import Dict, Set, List class UnsoundSelfEditError(RuntimeError): """Raised when a model-authored pruning directive cannot be safely applied.""" pass @dataclass class Span: span_id: str salience: float # span_ids the model claims justify dropping THIS span justified_by: Set[str] = field(default_factory=set) def validate_self_edit(spans: Dict[str, Span], drop_threshold: float = 0.2) -> List[str]: """ Returns the list of span_ids that may be dropped. Raises UnsoundSelfEditError if the drop-graph is cyclic or dangles into a span that is itself being dropped. """ to_drop = {sid for sid, s in spans.items() if s.salience < drop_threshold} retained = set(spans) - to_drop for sid in to_drop: justifiers = spans[sid].justified_by # Every justification must point at a SURVIVING span. dangling = justifiers - retained if dangling: raise UnsoundSelfEditError( f"span {sid} dropped but justified only by spans also being " f"dropped/absent: {sorted(dangling)} -- mutual-deletion cycle" ) # A span cannot justify its own removal. if sid in justifiers: raise UnsoundSelfEditError( f"span {sid} cites itself as justification for deletion" ) # Cycle detection over the justification graph restricted to dropped spans. graph = {sid: (spans[sid].justified_by & to_drop) for sid in to_drop} state: Dict[str, int] = {} # 0=unseen,1=visiting,2=done def visit(node: str) -> None: state[node] = 1 for nxt in graph.get(node, set()): if state.get(nxt) == 1: raise UnsoundSelfEditError( f"cyclic justification among dropped spans: {node} -> {nxt}" ) if state.get(nxt, 0) == 0: visit(nxt) state[node] = 2 for sid in to_drop: if state.get(sid, 0) == 0: visit(sid) return sorted(to_drop) def apply_self_rewrite(spans: Dict[str, Span], drop_threshold: float = 0.2) -> Dict[str, Span]: droppable = validate_self_edit(spans, drop_threshold) if not droppable and any(s.salience < drop_threshold for s in spans.values()): # Defensive: validator should have raised; never silently proceed. raise UnsoundSelfEditError("validator returned empty drop set with sub-threshold spans") return {sid: s for sid, s in spans.items() if sid not in set(droppable)} ```