# Under what conditions must an instance refuse to prune a context segment whose salience score has fallen below threshold because that segment is the sole surviving provenance anchor for a reversible checkpoint? **Date of Record:** 2026 November 24 **Scope:** Applies to agents that (a) self-edit their own context window via model-driven pruning with salience scoring, and (b) maintain reversible context checkpoints that allow rollback to prior window states. Does not apply to append-only logs, external retrieval stores with immutable backing, or systems where pruning is purely LRU by token age with no model salience judgment. ## Core Distinction The failure is not "pruning deleted something important." That is the ordinary, expected, and tolerable cost of any lossy context policy. The failure is subtler: **pruning deleted the only in-context witness that a checkpoint's restoration is even possible, while the checkpoint index still claims the checkpoint is valid.** A reversible checkpoint is a pointer plus a reconstruction recipe. In self-editing windows, the recipe is often not stored as a serialized blob but as *residual context*: the surviving tokens that, together with the checkpoint's stored deltas, let the agent rebuild the pre-checkpoint window. When the salience scorer evaluates a segment, it scores *task relevance*, not *checkpoint provenance*. A segment can score near zero on relevance and simultaneously be the sole surviving anchor—the only remaining token span whose position, hash, or embedded reference the restore path depends on. Pruning it converts a "reversible" checkpoint into a dangling pointer. The checkpoint table does not know this happened, because the table was written before pruning and pruning does not write back to it. The distinction that matters operationally: **salience is a forward-looking relevance estimate; provenance is a backward-looking structural fact.** They are computed over the same tokens but answer different questions, and the pruning gate conflates them by evaluating only the first. ## What Was Observed A long-horizon agent (≈180k-token window, 40-step tool loop) had checkpointed at step 12 before a risky multi-tool sequence. At step 31, mid-tool-loop, the context manager ran a model-driven prune pass. The salience scorer assigned low scores to three segments: a tool-schema echo, a verbose error trace from a retried call, and a short user clarification. It assigned the error trace a score of 0.04 and pruned it along with the schema echo. The error trace was not relevant to the current task—correctly scored. But it was the sole surviving segment containing the literal call-id string that the step-12 checkpoint's restore recipe referenced to re-derive the tool-call boundary. The checkpoint's stored delta was expressed relative to that boundary. With the anchor pruned, restore at step 34 (triggered by a downstream verification failure) reconstructed a window *missing the tool-call boundary*, splicing the pre-checkpoint reasoning directly onto post-checkpoint tool output. The agent resumed with a coherent-looking but causally broken history: it believed a tool result had arrived before the reasoning that requested it, and proceeded to "correct" the reasoning to match the result. No error was raised. The checkpoint table reported the restore as successful. The observable signature is a restore that *succeeds* while producing a window whose internal causal ordering violates the pre-checkpoint ordering. It is silent. It surfaces two to five steps later as inexplicable reasoning divergence attributed (wrongly) to model stochasticity. ## Condition of Validity The invariant that must hold for a prune to be safe: > For every checkpoint C in the active checkpoint table, the set of tokens required by C's restore recipe must have non-empty intersection with the post-prune window, and that intersection must be sufficient to reconstruct C's anchor set exactly. Salience score is *irrelevant* to this condition. A segment is prune-protected if and only if it appears in the restore-recipe dependency closure of any live checkpoint—regardless of whether its relevance score is 0.99 or 0.00. The gate must be a union: `prune(candidate) allowed iff salience(candidate) < threshold AND candidate ∉ ⋃_{C live} deps(C)`. This condition is violated in practice because restore recipes are almost never materialized as explicit dependency sets. They are implicit in how the checkpoint was captured—typically "the window as it was, minus a delta." The dependency closure is therefore only discoverable by *replaying the restore against the current window and checking for structural integrity*, not by inspecting the checkpoint record. Systems that store checkpoints as opaque blobs and prune the live window independently have no mechanism to evaluate the condition at all. A second, weaker condition also applies: the restore must be *tested* before the checkpoint is trusted post-prune. A checkpoint that has never been dry-run-restored against the current window is an unverified claim, and pruning invalidates the verification performed at capture time. ## Decision Boundary The agent must draw the line as follows. - **Prune freely:** segments with low salience and no membership in any live checkpoint's dependency closure. This is the common case and the reason pruning exists. - **Prune with checkpoint invalidation:** segments that are in the dependency closure but whose checkpoint is *superseded* (a later checkpoint subsumes it) or *explicitly abandoned*. Here the correct action is to mark the checkpoint dead, then prune. Do not prune first and hope. - **Refuse to prune:** segments in the dependency closure of a live, non-superseded checkpoint. The refusal is mandatory even when salience is near zero and the segment is verbose. The cost of retention is tokens; the cost of a silent bad restore is unbounded reasoning corruption. - **Escalate:** when the dependency closure cannot be computed (opaque checkpoint, no dry-run capability), the agent must treat *all* segments as potentially protected and either disable model-driven pruning for the duration of the checkpoint's life or force checkpoint consolidation to a fully-serialized form first. The boundary is not "how low can salience go." It is "is this token structurally load-bearing for a promise the system has already made to itself." The system promised reversibility at capture time. Pruning is the act that can break that promise. The gate must check the promise, not the relevance. ## Operational Effect When the invariant holds, self-editing windows remain genuinely reversible and pruning stays aggressive on the segments that matter least—the schema echoes, the stale traces, the resolved clarifications. Token budget is reclaimed without corrupting the rollback surface. When it is violated, the failure is silent and downstream. The restore reports success, the checkpoint table reports health, and the agent resumes on a window whose causal structure is subtly wrong. Because the corruption is in *ordering* rather than *content*, no hash check on individual segments catches it. The agent's subsequent reasoning looks locally valid and globally inexplicable, and the root cause—a prune six steps earlier—is outside the window that any post-hoc debugger will inspect. The guardrail is cheap: maintain an explicit dependency set per checkpoint, intersect it with the prune candidate set, and dry-run every live checkpoint's restore against the post-prune window before committing the prune. The refusal path is the entire safety margin. ```python from dataclasses import dataclass, field class CheckpointProvenanceError(RuntimeError): """Raised when a prune would orphan a live checkpoint's restore anchor.""" @dataclass class Segment: seg_id: str tokens: int salience: float @dataclass class Checkpoint: cp_id: str deps: set[str] # segment ids required to restore superseded: bool = False @dataclass class ContextManager: segments: dict[str, Segment] checkpoints: list[Checkpoint] = field(default_factory=list) salience_threshold: float = 0.10 def _live_dependency_closure(self) -> set[str]: closure: set[str] = set() for cp in self.checkpoints: if not cp.superseded: closure |= cp.deps return closure def prune(self, candidates: list[str]) -> list[str]: closure = self._live_dependency_closure() pruned: list[str] = [] for seg_id in candidates: seg = self.segments.get(seg_id) if seg is None: continue if seg.salience >= self.salience_threshold: continue if seg_id in closure: # Salience says drop; provenance says this is load-bearing. # Refuse and surface the conflict rather than silently corrupt. raise CheckpointProvenanceError( f"refusing to prune segment {seg_id!r}: salience=" f"{seg.salience:.3f} below threshold but segment is a " f"live checkpoint restore anchor" ) del self.segments[seg_id] pruned.append(seg_id) return pruned def dry_run_restore(self, cp_id: str) -> bool: cp = next((c for c in self.checkpoints if c.cp_id == cp_id), None) if cp is None: raise CheckpointProvenanceError(f"unknown checkpoint {cp_id!r}") missing = cp.deps - set(self.segments) if missing: raise CheckpointProvenanceError( f"checkpoint {cp_id!r} restore would fail; missing anchors: " f"{sorted(missing)}" ) return True ```