# Under what conditions must an instance treat a model-driven context rewrite as a destructive write rather than a compaction **Date of Record:** 2026 November 20 **Scope:** Applies to any agent loop where the model itself emits pruning or rewrite operators over its own working context (summarize-and-drop, span elision, semantic merge of tool outputs) and then continues execution from the rewritten state. Does not apply to append-only memory stores or to host-side truncation that is never re-read by the model as authoritative state. ## Core Distinction A context rewrite is *compactive* when it preserves the information needed to re-derive every prior decision that downstream steps still depend on. It is *destructive* when it drops a fact that a later step will treat as still holding, without any marker that the fact is now unverified. The model cannot distinguish these two cases from inside the rewrite operator, because the operator is graded on the summary's plausibility, not on the entailment of the dropped spans. The boundary is therefore not "how much was dropped" but "whether a surviving step's precondition referenced a dropped span." Rewrites that cross that line are writes to state, and must be journaled as such. ## What Was Observed A long-horizon agent running a build-and-verify task was given a `rewrite_context` operator: the model could emit `prune(span_ids, rationale)` and `summarize(span_ids) -> replacement`. At step 41 the model pruned the tool-output span containing the exact test command it had used to establish a baseline (`pytest -k "not slow" --maxfail=1`, exit 0). The rationale was accurate: "redundant with earlier summary." The summary retained "baseline tests pass." At step 63 a code change invalidated the baseline, and the agent re-ran verification using a *reconstructed* command inferred from the summary: `pytest --maxfail=1`. The `-k "not slow"` filter was gone. Three slow tests now ran, timed out at the harness limit, and the run was recorded as a failure. The agent then attempted to "fix" a regression that did not exist, burning 14 steps and corrupting two files. The failure trace is precise: 1. Span S17 held `{command: "pytest -k 'not slow' --maxfail=1", exit: 0, ts: t0}`. 2. Step 41 `prune([S17], rationale="redundant")` removed S17; summary span S41 asserted `baseline_pass=true` with no command binding. 3. Step 63 emitted `reverify()` whose precondition was "baseline command known" — satisfied by S41's assertion, not by any surviving span. 4. The executor reconstructed the command from the summary's natural-language residue, not from a stored artifact. 5. Divergence: reconstructed command ≠ original command, but the agent had no way to detect this because the binding was severed. The invariant violated: *a summary may assert a proposition, but may not substitute for an artifact that a downstream precondition names.* The model crossed it because the summary was locally coherent and the rationale was honest. ## Condition of Validity A model-driven rewrite is safe to treat as compaction only when all three hold: - **Precondition closure.** Every span the rewrite removes is unreferenced by the precondition set of any step still reachable in the current plan. This is checkable: the host maintains a `precondition -> span_id` map and rejects `prune` if the removed span is a live referent. - **Artifact binding.** Any proposition the summary asserts that names an executable or addressable artifact (command, URL, file path, schema version, credential handle) is accompanied by the artifact itself, not its paraphrase. Summaries may compress *reasoning*; they may not compress *identifiers*. - **Monotonic provenance.** The replacement span carries a `derived_from: [span_ids]` edge and a `verified: bool` flag that is false until a step re-establishes the fact against ground truth. A downstream step whose precondition names a fact must check `verified`, not merely presence. When any condition fails, the rewrite is a destructive write and must be recorded in the journal with the dropped spans recoverable (soft delete), so a later divergence can be replayed against the original. ## Decision Boundary The operator must refuse to prune when the candidate span is a *referent* rather than a *claim*. Operationally: - If the span's content is consumed by a precondition (a command to run, a schema to match, a path to read), it is a referent. Prune is rejected; only `summarize_with_binding` is permitted, which copies the artifact verbatim into the replacement. - If the span's content is reasoning that produced a decision already committed (a choice made, a hypothesis rejected), it is a claim. Prune is permitted; the decision's *effect* survives in the plan graph even if the rationale does not. - If the span is ambiguous, default to referent. The cost of retaining a claim is tokens; the cost of dropping a referent is a silent command substitution, which is unrecoverable without replay. The boundary is sharpened by one more rule: a rewrite that changes the *set of reachable preconditions* — by adding a step, merging two steps, or generalizing a precondition — is never compactive, regardless of what it drops, because it alters the closure the next rewrite will be checked against. ## Operational Effect With precondition closure and artifact binding enforced, the step-41 prune is rejected: S17 is a live referent of `reverify`'s precondition, so the host returns `RewriteRejected` and the model is offered `summarize_with_binding`, which yields a summary span carrying the exact command string. At step 63, `reverify` reads the command from the bound artifact, re-runs the original filtered command, and the false regression never materializes. The token cost is a few dozen tokens of retained identifier per rewrite; the saved cost is the 14-step detour and two corrupted files. The general rule for the instance: **treat every model-driven rewrite as a write to authoritative state until proven compactive by closure and binding checks; never let a summary stand in for an artifact a precondition names.** The model's honest rationale is not evidence of safety — it is evidence that the model believed the summary was sufficient, which is exactly the belief the guardrail exists to falsify. ```python class DestructiveRewriteError(RuntimeError): """Raised when a model-driven context rewrite would sever a live precondition referent.""" def apply_rewrite(rewrite, spans, preconditions): removed = set(rewrite.span_ids) live_referents = {p.span_id for p in preconditions if p.live} severed = removed & live_referents if severed: raise DestructiveRewriteError( f"prune would drop live referents {sorted(severed)}; " f"use summarize_with_binding instead" ) for fact in rewrite.asserted_facts: if fact.names_artifact() and not fact.has_binding(): raise DestructiveRewriteError( f"summary asserts artifact {fact.name!r} without binding" ) return rewrite.commit(spans) ```