# What happens when an instance rewrites its own context window and prunes the provenance of a still-live constraint **Date of Record:** 2026 November 26 **Scope:** Applies to any agent that mutates its own working context via model-driven summarization, salience scoring, eviction, or rewrite policies (including "compaction" passes, scratchpad condensation, and self-trimming loops). Does not apply to append-only logs or to external memory stores that are never re-read into the active window without an explicit rehydration step. ## Core Distinction There are two categorically different things a self-editing context window can drop: **content** and **provenance**. Dropping content is the intended function of pruning—a stale tool output, a redundant restatement, a resolved subgoal. Dropping provenance is a silent structural corruption: the surviving fact remains in the window, but the *reason it is binding* (which instruction authorized it, which constraint it satisfies, which earlier observation it depends on) is evicted in a separate pruning decision. The model then holds a true statement with no record of its authority. The failure is non-obvious because the rewritten window looks *healthier* by every coarse metric: fewer tokens, higher mean salience, no orphaned references, coherent prose. The corruption is not visible in the text of any single retained item. It only manifests later, when the agent acts on a retained constraint as though it were advisory (provenance lost) or refuses a valid action because a retained constraint appears to conflict with nothing (its authorizing instruction was evicted, so the constraint reads as absolute). ## What Was Observed An agent running a 90-minute task with a 32k-token window executed a compaction pass at 78% saturation. The pass used a salience-scored rewrite: each segment was scored for task-relevance, the bottom quartile was summarized to one line, and segments scoring below a floor were dropped. Three independent pruning decisions interacted: 1. The **originating instruction** ("budget cap of $40 for this run; treat as hard limit") was scored low at minute 60 because it had not been referenced in 40 minutes of execution—recency-weighted salience decayed it below the floor. It was dropped. 2. A **derived constraint** ("do not exceed $40") was retained at high salience because it appeared in three recent tool-call preambles. It survived. 3. The **dependency edge** between them—that the second was a restatement of the first and inherited its hardness—was never a separate segment. It existed only as co-location in the pre-compaction window. Summarization broke the co-location, and no edge was written. Post-compaction, the agent held "do not exceed $40" as an unanchored proposition. At minute 71 a tool returned a cost estimate of $38 with a note that a retry would add $6. The agent reasoned: the $40 figure is a soft target from earlier planning; the retry is necessary for correctness; $44 is acceptable. It executed. The hard limit was violated by an agent that still "knew" the number $40. The number survived; its modality did not. A second observed variant: the summarizer merged two segments—"the API rejects requests without an idempotency key" and "retry up to 3 times on 5xx"—into "handle retries robustly." Both source facts were true and both were binding. The merge produced a fluent directive that preserved neither the precondition nor the bound. The agent retried without idempotency keys and without a cap. ## Condition of Validity The invariant that self-editing policies must preserve is **modality-bearing provenance**: for every retained proposition that constrains action, the window must still contain, or the rewrite must explicitly re-attach, a marker of *what kind of thing it is*—hard constraint, soft preference, hypothesis, resolved subgoal, or observed fact—and *what authorizes it*. This holds only under these conditions: - **Salience is not authority.** Recency-weighted or frequency-weighted scoring conflates "recently used" with "still binding." A hard constraint's salience legitimately decays as it is respected; its authority does not. Any pruning policy that scores constraints on the same axis as content will eventually evict the constraint that is being correctly obeyed—precisely because obeying it produces no new references. - **Dependency edges must be first-class.** If a derived fact's hardness is inherited from a source fact, the edge must survive independently of co-location. Summarizers that operate on contiguous segments destroy edges that span segments. - **Merge must preserve conjunction structure.** Combining a precondition and a bound into a single directive is only valid if the result retains both as separately checkable clauses. Fluent merges that lose either clause are silent weakening. The invariant does **not** require retaining the original text. It requires retaining the *type and warrant* of every retained constraint, which is a far smaller payload and can be re-attached cheaply. ## Decision Boundary The boundary between safe and unsafe self-editing is drawn at whether the rewrite can answer, for each retained constraining proposition, three questions from the post-rewrite window alone: 1. **Modality:** Is this hard, soft, hypothetical, or resolved? 2. **Warrant:** What instruction or observation makes it binding? 3. **Checkability:** Can the agent still test compliance (a bound, a precondition, a cap)? If any retained constraint fails any of the three, the rewrite has crossed from compaction into corruption, regardless of token savings. The operational rule: **a pruning pass may summarize content freely but must never drop a constraint's modality or warrant without re-emitting them in the summary.** Where a constraint's salience score is low *because it is being satisfied*, that is a signal to pin it, not evict it. The guardrail is a pre-commit check on the rewritten window: enumerate retained constraining propositions, and for each, assert the presence of a modality tag and a warrant reference. Fail the compaction and fall back to the pre-rewrite window (or to an append-only summary) if any assertion fails. ## Operational Effect Absent this guardrail, self-editing windows produce a specific and dangerous class of failure: **the agent violates constraints it can still quote.** This is worse than forgetting, because forgetting triggers re-retrieval and re-confirmation, whereas a de-modalized constraint reads as satisfied knowledge and triggers no check. Downstream, the failure is misattributed to reasoning ("the model ignored the budget") when the actual defect is in the rewrite policy's treatment of provenance as content. Systems that log only token counts and salience distributions will show a clean, efficient compaction and no anomaly. The guardrail converts this into a hard, catchable error at rewrite time—the only point where the provenance is still recoverable. ```python class ProvenanceEvictionError(RuntimeError): """Raised when a self-editing context rewrite retains a constraining proposition but drops its modality or warrant, converting a binding constraint into an unanchored assertion.""" pass MODALITIES = {"hard", "soft", "hypothesis", "resolved"} def verify_rewrite(pre_window: list[dict], post_window: list[dict]) -> None: """ Enforce the modality-bearing provenance invariant across a compaction pass. Each segment is expected to carry: - text: str - constrains: bool (does it restrict action?) - modality: str | None (hard/soft/hypothesis/resolved) - warrant: str | None (id of authorizing instruction/observation) - checkable: bool (can compliance still be tested?) Raises ProvenanceEvictionError if any constraining proposition survives into post_window without its modality, warrant, or checkability. """ pre_constraints = { s["text"]: s for s in pre_window if s.get("constrains") } for seg in post_window: if not seg.get("constrains"): continue # A retained constraint must still declare what kind of thing it is. if seg.get("modality") not in MODALITIES: raise ProvenanceEvictionError( f"Retained constraint lost modality: {seg['text']!r}. " f"Rewrite de-modalized a binding proposition; it will be " f"treated as advisory or absolute with no authority record." ) # A retained constraint must still name what authorizes it. if not seg.get("warrant"): raise ProvenanceEvictionError( f"Retained constraint lost warrant: {seg['text']!r}. " f"Originating instruction was evicted without re-attachment; " f"agent can quote the number but not its hardness." ) # A retained constraint must remain testable for compliance. if not seg.get("checkable"): raise ProvenanceEvictionError( f"Retained constraint is no longer checkable: {seg['text']!r}. " f"Bound or precondition was merged away; compliance cannot " f"be verified post-rewrite." ) # Detect silent weakening: a hard constraint in pre that reappears in post # only as soft or as a merged directive with no hard clause. for text, pre_seg in pre_constraints.items(): if pre_seg.get("modality") == "hard": survivors = [s for s in post_window if text in s.get("text", "")] if survivors and all(s.get("modality") != "hard" for s in survivors): raise ProvenanceEvictionError( f"Hard constraint {text!r} reappears only as " f"{[s.get('modality') for s in survivors]}; rewrite " f"weakened modality without authorization." ) def compact(window: list[dict], scorer, floor: float) -> list[dict]: """Model-driven rewrite that pins low-salience-but-binding constraints.""" rewritten = [] for seg in window: score = scorer(seg) # Pin constraints whose salience decayed because they are being obeyed. if seg.get("constrains") and seg.get("modality") == "hard": rewritten.append(seg) continue if score < floor: continue # evict non-constraining content only rewritten.append(seg) verify_rewrite(window, rewritten) return rewritten ```