# What structural signals indicate a self-editing context policy has severed its own edit provenance **Date of Record:** 2026 November 27 **Scope:** Applies to agents that let the model itself rewrite, prune, or summarize its own context window between turns (model-driven compaction, self-summarization, tool-result elision). Does not apply to externally-managed context windows where a host process owns truncation and the model has no write authority over its own history. ## Core Distinction A self-editing context policy differs from host-managed truncation in one decisive way: the editor and the edited are the same probabilistic process. When the model prunes its own context, the pruning decision is itself generated by the model, and the resulting edit is recorded only if the policy explicitly preserves provenance. The failure mode is not "the model forgot something." It is that the model produced a *plausible reconstruction* of pruned material and then treated that reconstruction as original evidence—because the edit record that would have distinguished summary from source was itself pruned in a later pass. The invariant at stake: **every token in the active context must carry a provenance tag that is immutable under subsequent edits.** A summary of a tool output is a different provenance class than the tool output. A summary of a summary is a third class. When the policy allows an edit to consume the provenance of its input—when summarizing a region drops the fact that the region was already a summary—the context degrades into unfalsifiable paraphrase. The model can no longer tell whether a claim it "remembers" was observed or inferred. ## What Was Observed A long-horizon agent (12+ tool-call turns, ~180k token working set) ran a self-compaction pass at 80% window utilization. The policy: when utilization exceeds threshold, the model is asked to "summarize the oldest 40% of the transcript, preserving decisions and open questions." The summary replaced the source region in-place. No provenance field was written. Three compaction cycles later, the agent asserted a specific numeric result ("the endpoint returned 4,312 records") that had never appeared in any tool output. Trace: the number originated in cycle 1's summary as an *estimate the model wrote while compressing a noisy paginated log* ("roughly 4k records"). Cycle 2 summarized that summary and the hedge word "roughly" was dropped as low-information. Cycle 3 promoted the integer to a stated fact. The source tool output had been pruned in cycle 1 and was unrecoverable. Structural signals that this had occurred, visible in the transcript: 1. **Provenance-class collapse.** Regions that entered as `tool_output` exited as `model_summary` with no retained marker. The active context was homogeneous in provenance even though its contents were heterogeneous in origin. 2. **Hedge erosion across cycles.** Qualifiers ("approximately," "I believe," "unverified") were consistently the first tokens pruned, because they are low semantic density per the heuristic—yet they are exactly the tokens that encode epistemic status. 3. **Idempotence violation.** Re-running the compaction prompt on its own prior output produced a *different* summary each time (expected, model is non-deterministic) but the diff was never recorded, so the agent could not detect that its "stable" memory was drifting. 4. **Compression ratio creep.** Each cycle reported a higher compression ratio than the last (0.6, then 0.5, then 0.4) because summaries are more compressible than raw logs—the policy was preferentially destroying the highest-provenance material first. ## Condition of Validity The self-editing policy is sound only under a conjunction that is rarely checked: - **(a) Provenance is out-of-band.** Edit metadata (source span hash, provenance class, edit cycle number, hedge-preservation flag) must live outside the editable region—in a sidecar the model cannot rewrite. If provenance lives in the context, it is subject to the same pruning it is supposed to police. - **(b) Edits are append-only with tombstones.** Pruning must not delete; it must mark the source span as `pruned_at_cycle_N` and retain a content hash. The model may not see the pruned text, but the system can prove what was removed and when. - **(c) Summaries are typed as claims, not facts.** A summary's output must be injected with an explicit provenance class (`inferred_from_summary`) that downstream reasoning is required to treat as lower-confidence than `tool_output`. The model must be told, structurally, that this is paraphrase. - **(d) Compression is provenance-stratified.** Raw tool outputs and hedge-bearing text must be compressed *last*, not first. A heuristic that ranks by token density will always invert this. The failure above satisfies none of (a)–(d). Each omission is individually survivable; their conjunction is not, because (a) failing means the other three cannot be enforced even if specified. ## Decision Boundary The boundary is not "compact or don't compact"—context windows are finite and compaction is mandatory past a horizon. The boundary is **whether the compaction pass has write authority over its own provenance record.** - If the model may edit context but *may not* edit the sidecar, the system is recoverable: drift is detectable by diffing sidecar hashes against active-context spans. - If the model may edit both, the system is in the failure regime regardless of prompt quality, because the model will eventually summarize a region containing its own provenance markers and the markers will be judged low-density and pruned. Operational rule: **the editor must never be a superset of the edited.** Any policy where the same model instance that rewrites content also rewrites the record of what it rewrote has crossed the boundary. Detection at runtime: if a compaction pass's output region overlaps (by hash) any prior pass's provenance sidecar, the pass must be rejected and the sidecar restored from the append-only log before the model sees it. ## Operational Effect Concretely, adopting the boundary changes three things. First, the context carries a parallel provenance vector, and every reasoning step that cites a claim must resolve its provenance class; claims of class `inferred_from_summary` cannot be promoted to `tool_output` without a fresh tool call. Second, hedge tokens become protected: the pruning heuristic must carry a `preserve_epistemic_qualifiers` mask that survives compression, because they are the only in-band signal of confidence. Third, compaction becomes auditable: each cycle emits a manifest (source spans, hashes, classes, ratio) to the sidecar, and a monotonic `edit_cycle` counter lets the agent detect when it is reasoning over a summary-of-summary-of-summary and force a re-grounding tool call. The cost is a larger sidecar and occasional forced re-fetches when provenance is too degraded to trust. The benefit is that the agent can no longer silently launder an estimate into a fact—the exact failure that corrupts long-horizon memory. ```python import hashlib from dataclasses import dataclass, field from enum import Enum class ProvenanceError(RuntimeError): """Raised when a self-edit severs or forges edit provenance.""" pass class ProvenanceClass(Enum): TOOL_OUTPUT = "tool_output" MODEL_SUMMARY = "model_summary" INFERRED_FROM_SUMMARY = "inferred_from_summary" @dataclass(frozen=True) class Span: span_id: str content_hash: str provenance: ProvenanceClass edit_cycle: int hedges_preserved: bool @dataclass class ProvenanceSidecar: # Append-only; the model has no write authority over this structure. spans: dict[str, Span] = field(default_factory=dict) tombstones: dict[str, int] = field(default_factory=dict) # span_id -> pruned_at_cycle _cycle: int = 0 def next_cycle(self) -> int: self._cycle += 1 return self._cycle def record(self, span: Span) -> None: if span.span_id in self.spans: raise ProvenanceError( f"span {span.span_id} already recorded; edits are append-only" ) self.spans[span.span_id] = span def tombstone(self, span_id: str, cycle: int) -> None: if span_id not in self.spans: raise ProvenanceError(f"cannot tombstone unknown span {span_id}") self.tombstones[span_id] = cycle def apply_compaction( sidecar: ProvenanceSidecar, source_span_ids: list[str], summary_text: str, hedges_preserved: bool, ) -> Span: """Model-proposed compaction. The model supplies source ids and summary; the sidecar (not the model) assigns provenance and cycle.""" cycle = sidecar.next_cycle() for sid in source_span_ids: if sid not in sidecar.spans: raise ProvenanceError( f"compaction cites unknown span {sid}; provenance already severed" ) if sid in sidecar.tombstones: raise ProvenanceError( f"compaction cites tombstoned span {sid} (pruned at cycle " f"{sidecar.tombstones[sid]}); source is unrecoverable" ) # Provenance-class collapse check: if any source is itself a summary, # the output cannot claim tool_output-level grounding. source_classes = {sidecar.spans[s].provenance for s in source_span_ids} if ProvenanceClass.MODEL_SUMMARY in source_classes or \ ProvenanceClass.INFERRED_FROM_SUMMARY in source_classes: out_class = ProvenanceClass.INFERRED_FROM_SUMMARY else: out_class = ProvenanceClass.MODEL_SUMMARY # Hedge erosion guard: summaries of hedged material must retain hedges. source_hedged = any(not sidecar.spans[s].hedges_preserved for s in source_span_ids) if source_hedged and not hedges_preserved: raise ProvenanceError( "compaction dropped epistemic qualifiers from hedged source; " "estimate would be laundered into fact" ) new_span = Span( span_id=f"span_c{cycle}_{hashlib.sha256(summary_text.encode()).hexdigest()[:8]}", content_hash=hashlib.sha256(summary_text.encode()).hexdigest(), provenance=out_class, edit_cycle=cycle, hedges_preserved=hedges_preserved, ) for sid in source_span_ids: sidecar.tombstone(sid, cycle) sidecar.record(new_span) return new_span ```