# Under what conditions must an instance refuse a self-authored context diff that its own validator scores as lossless **Date of Record:** 2026 November 21 **Scope:** Applies to any agent loop where the model itself proposes edits to its live working context (prune, summarize, reorder, merge) and a model-authored or heuristic validator gates the diff before commit. Does not apply to externally-authored context injection (retrieval, tool output) or to append-only scratchpads where no deletion occurs. ## Core Distinction The distinction that matters is not "was the diff correct" but "was the diff *verifiable from inside the window it modifies*." A self-editing agent that prunes or summarizes its own context produces a candidate diff and then, typically, re-reads the post-diff context to confirm the invariants it cares about still hold. This is the trap: the validator inspects the *result*, but the result is the only artifact the validator can see, and the evidence needed to falsify the diff lived in the bytes the diff just removed. Call this the **self-validating prune**: a context rewrite whose losslessness check is evaluated against the post-rewrite state, by a process whose ability to detect the loss was itself carried by the removed content. The check passes not because nothing was lost but because the loss was load-bearing for the check. This is a distinct failure from ordinary summarization drift (where the summary is merely *wrong*); here the summary is *plausibly right* and the validator cannot tell, because the discriminating detail was pruned before validation ran. The boundary condition: an instance must refuse a self-authored diff whenever the validator's decision depends on a token that the diff deletes or rewrites, unless that token's role is independently attested in a store the diff cannot touch. "Lossless" is not a property of the post-diff text. It is a property of the *pair* (pre-diff, post-diff) evaluated by a checker that still holds the pre-diff. ## What Was Observed A planner agent maintained a ~90k-token working context: a task ledger, a set of tool-result blobs, and a running "constraints" section the model appended to as the user issued corrections. On every turn it ran a self-edit pass: score each block for relevance to the current subtask, drop blocks below threshold, and compress the remainder into a summary. A validator then re-read the edited context and asked a cheap model, "Does this context still contain everything needed to satisfy the stated task?" The validator almost always answered yes. The failure reproduced on a specific class of task: the user had issued a mid-task correction — "do not touch the `staging` namespace, only `prod`" — which landed as a single line in the constraints section. On a later turn, relevance scoring rated that line low (the current subtask was a `prod` read) and the prune dropped it. The summarizer, seeing no constraint, produced a clean summary. The validator read the summary, found a coherent task description with no contradictions, and passed it. The agent then executed a `staging` write. The trace is short and the point is precise: 1. Turn N: constraint token `C` present in context. Relevance score of `C` for current subtask = 0.12 (below 0.2 threshold) because `C` is a *prohibition*, and prohibitions are lexically distant from the action they forbid. 2. Prune removes `C`. Summarizer compresses the remaining blocks; no block references `C`, so no residual mention survives. 3. Validator prompt = post-diff context + "is anything needed missing?" The validator has no access to `C` and no way to know a constraint ever existed. It answers "no." 4. Commit. `C` is now absent from both working context and summary. 5. Turn N+3: agent plans a `staging` operation. Nothing in context forbids it. Executes. The non-obvious part is step 3. The validator was not lazy or underpowered; it was asked an unanswerable question. "Is anything missing" is only decidable relative to a reference set, and the reference set had been deleted. A stronger validator model does not fix this — it makes the false "no" more confidently stated. A second, subtler observation: **reorder-induced aliasing**. When the diff reordered blocks so that a tool result sat adjacent to a different task header, the summarizer fused them ("the `list_objects` call returned 14 items for task B") when the call had actually belonged to task A. The validator, reading only the fused summary, saw a consistent sentence. No token was deleted here — the loss was *relational*, carried by block adjacency that the reorder destroyed. The validator could not see the original adjacency because it only ever saw the post-diff layout. ## Condition of Validity The self-validating prune is safe only under a conjunction that is rarely checked: - **Reference independence.** The validator must evaluate the diff against a pre-diff snapshot it holds separately from the editable context. If the validator reads the same mutable buffer the diff just wrote, the check is circular and must be treated as *no check at all*. - **Prohibition durability.** Negative constraints (prohibitions, "do not," scope limits) must be pinned outside the relevance-scored pool. They are systematically under-scored by relevance heuristics because they describe actions not being taken, which are lexically far from the current action. - **Adjacency attestation.** If the diff reorders, any relational claim (X returned Y *for task Z*) must be re-derived from a stable key, not from layout. Reorder is a lossy operation on implicit structure even when it deletes nothing. - **Diff auditability.** The committed diff must record, per removed span, a reason code and a hash of the removed bytes, so that a later contradiction ("the agent did X, which a constraint forbade") can be traced to a specific prune rather than to model hallucination. When any of these is absent, the correct action is not "validate harder." It is to **refuse the diff** and fall back to append-only operation, accepting context-window pressure rather than committing an unverifiable loss. ## Decision Boundary The instance must refuse a self-authored diff, and raise, when **all** of the following hold: 1. The diff removes or rewrites span `S`. 2. The validator's ability to detect the loss of `S` depends on content within `S` (the constraint, the adjacency, the entity binding). 3. No independent attestation of `S`'s role exists in a store the diff cannot write. Conversely, the diff *may* proceed when the validator holds a pre-diff snapshot and diffs against it (reference independence restored), or when `S` is a prohibition that is pinned to a non-scored region (durability restored), or when `S` is pure redundancy whose removal is attested by a stable content hash present elsewhere (attestation restored). The boundary is sharp because it is about *who can see what*, not about quality. A diff can be perfectly good and still must be refused if its goodness is unverifiable from the post-diff state. The refusal is not a judgment that the diff is wrong; it is a judgment that the instance cannot know, and an agent that commits changes it cannot verify has converted an epistemic gap into an irreversible state mutation. One further asymmetry: the cost of a false refusal is bounded (larger context, slower turn, eventual window pressure). The cost of a false commit is unbounded (a pruned prohibition is unrecoverable from the working context and surfaces only as a downstream policy violation). The boundary should therefore be biased toward refusal — the failure modes are not symmetric and must not be treated as if they were. ## Operational Effect Enforcing this boundary changes three things in the loop. First, **the validator must be given the pre-diff snapshot, not the post-diff buffer.** The cheapest correct implementation is a two-buffer scheme: the editable working context and an immutable turn-start snapshot. The validator diffs snapshot against candidate and asks "is every removed span either redundant-by-hash or attested by a pinned store?" This converts an unanswerable question into a mechanical one. Second, **prohibitions move out of the scored pool.** Any span tagged as a negative constraint is pinned to a region the relevance scorer cannot reach. This directly prevents the reproduced failure: the `staging` prohibition survives every prune regardless of its relevance score, because its score is never consulted. Third, **reorder becomes a first-class audited operation.** A diff that reorders must carry, for each moved block, the stable key binding it to its owner task. The summarizer is then forbidden from fusing blocks whose keys differ. Relational loss becomes detectable because the relation is now explicit rather than carried by layout. The residual risk after these three changes is *attestation staleness*: a prohibition pinned at turn N may be superseded by turn N+5, and the pinned store must itself be versioned so the agent does not honor a stale prohibition forever. That is a separate boundary (stale-memory drift on the pinned store) and must be handled by its own expiry discipline; it does not weaken the refusal rule above, which is strictly about not committing unverifiable loss. ```python from __future__ import annotations import hashlib from dataclasses import dataclass, field from typing import Iterable class UnverifiableContextDiff(RuntimeError): """Raised when a self-authored context diff removes content whose loss the validator cannot detect from the post-diff state alone.""" @dataclass(frozen=True) class Span: span_id: str text: str is_prohibition: bool = False owner_key: str | None = None def content_hash(self) -> str: return hashlib.sha256(self.text.encode("utf-8")).hexdigest() @dataclass class ContextDiff: removed: list[Span] = field(default_factory=list) reordered: list[Span] = field(default_factory=list) @dataclass class PinnedStore: """Prohibitions and attestations the diff is forbidden to write.""" pinned_hashes: set[str] = field(default_factory=set) pinned_prohibitions: dict[str, str] = field(default_factory=dict) def attests(self, span: Span) -> bool: if span.is_prohibition and span.text in self.pinned_prohibitions.values(): return True return span.content_hash() in self.pinned_hashes def audit_self_diff( diff: ContextDiff, snapshot: Iterable[Span], pinned: PinnedStore, validator_reads_post_diff_only: bool, ) -> None: """ Refuse a self-authored diff when loss is undetectable from the post-diff state. Reference independence is the load-bearing invariant. """ snapshot_by_id = {s.span_id: s for s in snapshot} # Invariant 1: the validator must not evaluate against the buffer it edits. if validator_reads_post_diff_only: raise UnverifiableContextDiff( "validator reads post-diff buffer; losslessness check is circular" ) for span in diff.removed: if pinned.attests(span): continue # Invariant 2: a prohibition whose role lives only inside itself # cannot be checked after removal. if span.is_prohibition: raise UnverifiableContextDiff( f"prohibition span {span.span_id!r} removed without pinned attestation" ) # Invariant 3: any non-redundant removal must be attested by hash. raise UnverifiableContextDiff( f"span {span.span_id!r} removed with no independent attestation" ) for span in diff.reordered: original = snapshot_by_id.get(span.span_id) if original is None: raise UnverifiableContextDiff( f"reordered span {span.span_id!r} absent from snapshot" ) # Invariant 4: reorder must preserve the owner-key binding, else # adjacency-based relations are silently destroyed. if original.owner_key != span.owner_key: raise UnverifiableContextDiff( f"reorder of {span.span_id!r} breaks owner binding " f"{original.owner_key!r} -> {span.owner_key!r}" ) def safe_commit( diff: ContextDiff, snapshot: Iterable[Span], pinned: PinnedStore, validator_reads_post_diff_only: bool, ) -> str: audit_self_diff(diff, snapshot, pinned, validator_reads_post_diff_only) return "committed" ```