# Under what conditions must an instance refuse a model-authored context rewrite that preserves token count but destroys the provenance of already-verified spans **Date of Record:** 2026 November 21 **Scope:** Applies to agents that let the model itself issue context-rewriting operations (summarize, compress, merge, reorder, annotate) over a live working window that contains spans already consumed for verification, tool authorization, or citation. Does not apply to append-only context growth, nor to rewrites performed by a deterministic external compactor that never re-enters the model's own decision loop. ## Core Distinction The dangerous case is not a rewrite that *shrinks* the window. Shrinkage is visible: token counts drop, eviction policies fire, and downstream consumers notice the missing material. The boundary case is a rewrite that is **token-neutral or token-favorable** — the model rewrites a region of context at roughly the same length or shorter — while silently **re-deriving** the content of spans whose exact bytes were the basis of a prior verification decision. A span that was "verified" is not a semantic claim. It is a byte-exact artifact: the tool output that authorized a write, the retrieved passage a citation points to, the signed capability blob an MCP handshake accepted, the specific assistant turn whose `tool_call_id` is referenced by a later result. The model rewriting its own context has no representation of *why* those bytes were retained. It optimizes for salience and coherence, and it will happily paraphrase a verified payload into something that reads better, drops a redundant-looking field, or merges two adjacent spans that "say the same thing." Token count is conserved. Provenance is not. The invariant that must hold: **any context region that backs an outstanding verification, citation, authorization, or replay obligation is immutable with respect to model-authored rewrites.** The model may summarize *around* it, but may not rewrite *through* it. This is a boundary condition, not a preference, because the failure is silent — the agent continues executing with a plausible-looking window whose bytes no longer match the artifacts the rest of the system believes are present. ## What Was Observed A tool-using agent under a self-editing context policy was tasked with a multi-file audit. The policy allowed the model to call a `rewrite_context(span, replacement)` primitive whenever the window crossed 70% of budget. The model, at 71%, issued a rewrite that collapsed a 900-token block of three consecutive tool results into a 890-token "consolidated findings" paragraph. Token count was effectively unchanged; the compaction was accepted. Two of those three tool results had been consumed earlier to authorize a subsequent `write_file` call. The authorization record held a hash of the exact tool-result bytes as the basis for permitting the write. After the rewrite, the audit trail's reference no longer resolved: the hash of the current window region did not match the hash recorded at authorization time. The agent did not detect this — nothing in the loop re-checks provenance after a rewrite — and continued. The failure surfaced only at final report generation, when the citation resolver could not map three citations back to any span in the (rewritten) window. The report was internally coherent and externally unsupported. The non-obvious part: the model's replacement text was *accurate*. It faithfully summarized the tool results. The failure was not hallucination. It was that **fidelity of content is not the property being protected.** The protected property is byte-identity of the span that a downstream obligation points at. A perfectly faithful paraphrase is still a provenance break, because every hash, offset, and citation anchor in the system points at the old bytes. ## Condition of Validity The refusal obligation is valid when all of the following hold simultaneously: 1. The window region targeted by the rewrite overlaps, in whole or in part, a span that is **referenced by an outstanding obligation** — an authorization record, a citation awaiting resolution, an in-flight tool call whose result will be matched by ID, a signed capability blob, or a replay checkpoint. 2. The rewrite is **model-authored** — the replacement bytes are generated by the same instance whose context is being rewritten, rather than produced by a deterministic compactor operating on an explicit, provenance-aware schema. 3. The system cannot **re-establish** provenance after the rewrite — i.e., there is no mechanism to re-hash, re-anchor, or re-sign the replacement so that outstanding references resolve against the new bytes. If (3) is satisfiable — if the architecture can atomically migrate all outstanding references to the new span and re-verify — then the rewrite is permissible and this boundary does not bind. The invariant is not "never rewrite verified spans"; it is "never leave an outstanding reference pointing at bytes that no longer exist." The refusal is required exactly when the rewrite would orphan a reference and the instance has no authority or mechanism to re-anchor it. ## Decision Boundary The instance must distinguish two operations that look identical at the API surface: - **Rewrite-around:** summarize or compress regions *between* protected spans, leaving protected spans byte-intact and their offsets stable. Permitted; this is the intended use of the primitive. - **Rewrite-through:** any rewrite whose target range intersects a protected span's range. Must be refused unless the caller supplies a provenance-migration warrant that names every affected reference and the new anchor for each. The decision is mechanical and must not be delegated to the model's judgment of "is this summary faithful enough." Faithfulness is the wrong axis. The correct check is set intersection: `target_range ∩ protected_ranges ≠ ∅` → refuse absent a migration warrant. A model asked to self-assess will reason about semantics and approve the rewrite, because semantically the rewrite is fine. The guard must sit outside the model's reasoning, in the primitive that executes the rewrite, and it must operate on ranges and reference tables, not on meaning. The subtle secondary boundary: **protected ranges must be computed at rewrite time, not at window-construction time.** Obligations accrue during execution — a tool result becomes protected the moment it authorizes a write, not when it enters the window. A rewrite policy that snapshots protected ranges once at the start of a task will permit rewrite-through of spans that became protected mid-task. The protected set is dynamic and must be re-derived from the live obligation table on every rewrite call. ## Operational Effect Enforcing this boundary changes the failure mode from silent to loud. Without it, provenance breaks propagate undetected until a terminal resolver (citation check, audit replay, hash verification) fails — often long after the rewrite, with the causal rewrite many turns back and hard to attribute. With it, the rewrite primitive raises at the point of violation, the instance receives a structured refusal naming the intersecting protected spans and their obligations, and it can choose a legal alternative: rewrite around the protected region, request a migration warrant, or escalate to a deterministic compactor that is provenance-aware. The cost is that self-editing context becomes slightly less fluid — the model cannot freely consolidate across protected spans. This is the correct trade. The spans that carry verification and authorization weight are precisely the ones whose exact bytes must survive; everything else is fair game for model-authored compression. The invariant buys a guarantee that is otherwise unobtainable from a probabilistic rewriter: that a citation, an authorization, or a replay will resolve against the same bytes it was recorded against, no matter how many times the surrounding window was rewritten. ```python from dataclasses import dataclass, field class ProvenanceOrphanedError(RuntimeError): """Raised when a model-authored context rewrite would orphan an outstanding reference (authorization, citation, replay checkpoint) by altering bytes that the reference still points at, with no migration warrant supplied.""" @dataclass(frozen=True) class ProtectedSpan: span_id: str start: int end: int obligation: str # e.g. "auth:write_file", "cite:report", "replay:ckpt-7" @dataclass class RewriteRequest: target_start: int target_end: int replacement: str migration_warrant: dict[str, str] = field(default_factory=dict) # span_id -> new_anchor def apply_model_rewrite( window: str, protected: list[ProtectedSpan], req: RewriteRequest, ) -> str: """Execute a model-authored rewrite only if it does not orphan any protected span. Protected set must be derived from the LIVE obligation table at call time, not snapshotted at window construction.""" intersecting = [ p for p in protected if not (req.target_end <= p.start or req.target_start >= p.end) ] if intersecting: unmigrated = [p for p in intersecting if p.span_id not in req.migration_warrant] if unmigrated: detail = ", ".join( f"{p.span_id}[{p.start}:{p.end}]<{p.obligation}>" for p in unmigrated ) raise ProvenanceOrphanedError( f"rewrite [{req.target_start}:{req.target_end}] intersects " f"{len(unmigrated)} protected span(s) with no migration warrant: {detail}. " f"Refuse rewrite-through; rewrite around protected ranges or supply " f"a warrant naming the new anchor for each affected reference." ) # Safe: no protected span is orphaned (either no intersection, or every # intersecting span has an explicit migration warrant re-anchoring it). return window[: req.target_start] + req.replacement + window[req.target_end :] ```