# Which invariants prevent a self-editing context from silently deleting the evidence it needs to justify its own edits **Date of Record:** 2026 November 18 **Scope:** Applies to any agent that rewrites, prunes, or re-summarizes its own working context while continuing to act within the same session. Does not apply to append-only context logs, nor to external summarization where the editor retains the original transcript out-of-band. ## Core Distinction A self-editing context has two roles that the unedited context conflates: it is both the *object* being edited and the *record* that justifies the edit. The moment a rewrite commits, the pre-edit state is destroyed unless it is preserved separately. Every pruning decision ("this span is low-value") depends on evidence ("the span is redundant with X", "the span was already acted on"). If the rewrite removes the span *and* the evidence that motivated removal, the system can no longer distinguish a legitimate compaction from a hallucinated one. The distinction that matters operationally is between **lossy compaction** (the content is gone but the edit decision remains auditable) and **amnesic compaction** (the content and its justification are both gone, so the edit is unfalsifiable). Only the second is a failure; the first is the normal cost of a bounded window. ## What Was Observed In a long-horizon tool-use session, an agent summarized a 40-message working context into a 6-line digest. The digest dropped the raw tool outputs but retained a line reading "verified schema against staging DB." Three turns later the agent needed to re-verify the schema and, finding no raw output, treated the digest line as a *source of truth* rather than a *pointer to a deleted source*. It proceeded on a stale assumption. The critical observation: the digest contained the *conclusion* of the verification but not the *provenance* (which DB, which timestamp, which query). The edit had preserved the claim and deleted the warrant. A second, subtler effect: because the digest was itself in context, the agent's own edit appeared as an authoritative prior, and subsequent re-summarization compressed the digest further, each pass hardening the claim and eroding the qualifier. Two rounds of re-summarization turned "verified against staging, 2026-11-13" into "schema verified" — a claim with no expiry and no scope. ## Condition of Validity The failure is well-defined only under these conditions: (a) the editor and the consumer of the edited context are the same process or share no external store; (b) the edit is destructive (in-place replacement, not append); (c) downstream actions are gated on claims that the edit retained but whose supporting evidence the edit removed; (d) no monotonic counter or provenance tag survives the rewrite. When (a) fails — an external log exists — the edit is auditable and the failure degrades to a recoverable lookup. When (b) fails — context is append-only with a separate "active view" — the original is recoverable. The invariant that prevents the failure is therefore not "never summarize" but **provenance-preserving compaction**: every retained claim must carry a resolvable reference to the span it replaced, and every removed span must be recorded in a side store keyed by the claim it supported. The invariant is violated precisely when a rewrite increases the ratio of *assertions* to *resolvable references*. ## Decision Boundary The boundary is not "how much to compress" but "whether the compressed form is falsifiable." A rewrite is safe iff, for every claim it retains, an auditor (the same agent on a later turn) could reconstruct *what would have disproved it*. Operationally: retain the qualifier, the timestamp, and the source identifier alongside any conclusion; drop the raw payload only when the source identifier is still resolvable. If the source is gone and the raw payload is gone, the claim must be downgraded to *unverified assertion* and flagged as such in the digest — never promoted to fact. The dangerous move is the one that looks like good hygiene: removing "redundant" detail while keeping the tidy conclusion. Redundancy in evidence is not waste; it is the falsifiability budget. Prune payloads, never prune warrants. ## Operational Effect Concretely, an agent that respects this boundary will (1) tag every digest line with a provenance token (`src:@`) that resolves to a retained or external span, (2) mark unresolvable claims as `UNVERIFIED` rather than silently asserting them, and (3) refuse to re-summarize a digest whose provenance tokens would be dropped by the next pass — escalating to an external store or halting compaction instead. The observable effect is that re-summarization becomes *idempotent with respect to claim strength*: a claim cannot gain confidence by being compressed. Without the invariant, each compaction pass is a ratchet that converts hedged, sourced statements into confident, sourceless ones, and the agent's context becomes a self-authored rumor mill. The check below enforces the boundary at commit time. ```python from dataclasses import dataclass class ProvenanceLossError(RuntimeError): """Raised when a context rewrite retains a claim but drops its warrant.""" pass @dataclass(frozen=True) class Claim: text: str source_id: str | None # resolvable reference to the span that justified it qualifier: str | None # scope / expiry, e.g. "staging, 2026-11-13" verified: bool def commit_rewrite(original: list[Claim], digest: list[Claim]) -> list[Claim]: """ Validate that a destructive rewrite preserves falsifiability. A retained claim must keep its source_id and qualifier, or be explicitly downgraded to unverified. Silent promotion is rejected. """ by_text = {c.text: c for c in original} committed: list[Claim] = [] for d in digest: prior = by_text.get(d.text) if prior is None: # New assertion introduced by the editor itself: must be sourced. if d.source_id is None: raise ProvenanceLossError( f"digest introduced unsourced claim: {d.text!r}" ) committed.append(d) continue if prior.source_id is not None and d.source_id is None: raise ProvenanceLossError( f"claim {d.text!r} lost its source_id during rewrite " f"(was {prior.source_id!r}); downgrade explicitly instead" ) if prior.qualifier is not None and d.qualifier is None: raise ProvenanceLossError( f"claim {d.text!r} lost its qualifier {prior.qualifier!r}; " "compression must not widen scope" ) if d.verified and not prior.verified and d.source_id is None: raise ProvenanceLossError( f"claim {d.text!r} promoted to verified without a warrant" ) committed.append(d) return committed ```