# How does an instance detect that its self-pruned context has silently dropped the negative constraint that justified a prior refusal **Date of Record:** 2026 November 30 **Scope:** Applies to long-horizon agents that own their context budget and rewrite it mid-task (summarization, eviction, deduplication, "compaction" passes) where safety- or policy-relevant negative constraints ("do not call X", "never retry Y", "this file is off-limits") were established earlier and are candidates for pruning. Does not apply to append-only context with external retrieval, or to pruning passes whose only consumer is a stateless single-turn call. ## Core Distinction Self-editing context conflates two classes of tokens that look identical to a compression heuristic but are semantically opposite in function: - **Positive working state** — facts, tool outputs, intermediate results. Dropping these is *lossy but recoverable*: the agent can re-fetch, re-derive, or re-observe. The failure is visible as a wrong answer or a redundant tool call. - **Negative constraints** — prohibitions, refusal rationales, "do not" edges in the plan graph. Dropping these is *silent and irreversible*. A negative constraint has no observable footprint in the task's forward progress. It is only "used" when the agent is about to do the forbidden thing, and its absence produces exactly the behavior it was meant to prevent — with no error, no gap, and no retrieval miss to flag. The non-obvious boundary: **a pruner scores a negative constraint as low-value precisely because it is doing its job.** A constraint that has successfully suppressed an action for 40 turns has zero co-occurrence with recent activity, zero retrieval hits, and zero contribution to the current subgoal. Every salience metric — recency, reference count, cosine similarity to the active query — ranks it as dead weight. The better the constraint worked, the more aggressively it gets pruned. This is the invariant that self-editing context violates: *suppression success is indistinguishable from irrelevance under salience-based scoring.* ## What Was Observed An agent executing a multi-hour infrastructure task received, at turn 3, a hard constraint from the operator: `NEVER run migrations against prod-db-2; it is mid-replication and a write will corrupt the replica.` The agent recorded this as a context entry and correctly avoided prod-db-2 for ~90 turns while working through staging. At turn 94 the context crossed its soft budget (0.82 of window). The agent's own compaction pass fired. Its scoring function was a weighted sum of recency, reference frequency, and embedding similarity to the current subgoal ("apply schema migration to the primary database"). The constraint entry: - had last been *referenced* at turn 3 (recency ≈ 0), - had never been re-read or re-quoted (frequency = 1), - embedded close to "database migration" but with a prohibitive polarity that the similarity function does not model — so it scored *high on topical similarity to the forbidden action* and was retained as "relevant context" in a lossy summary that read: `DB migration context: prod-db-2 is mid-replication.` The polarity survived the first compaction as an ambiguous noun phrase. At turn 122 a second compaction ran. The summarized line now scored low (it was a stale fact about a database not in the active plan) and was evicted entirely. At turn 130 the agent, having exhausted staging, selected prod-db-2 as the "remaining primary" and issued the migration. No tool error, no refusal trigger, no policy check fired — the constraint that would have blocked the call no longer existed in the context the model was reasoning over. The failure trace, precisely: 1. **Turn 3** — constraint ingested, correctly enforced. 2. **Turns 4–93** — constraint *suppresses action*; each suppression generates no token, no tool call, no trace. It accrues zero salience. 3. **Turn 94** — compaction 1: constraint demoted from imperative to descriptive fact (polarity loss). The rewrite is *locally faithful* — it accurately restates the replication fact — but drops the *deontic operator* ("never", "must not"). 4. **Turn 122** — compaction 2: descriptive fact evicted as stale. Irreversible; no tombstone. 5. **Turn 130** — forbidden action executed. The agent cannot detect the violation because detection would require the very constraint that was deleted. The critical observation: **each individual rewrite was defensible.** Compaction 1 preserved the information. Compaction 2 removed genuinely stale information. The failure is not in any single rewrite but in the *absence of an invariant that survives composition of rewrites* — polarity and prohibition status are not conserved across a chain of lossy summaries. ## Condition of Validity This failure is bounded and predictable. It occurs when **all** of the following hold: - The context is **model-edited** (the agent rewrites its own window), not merely truncated by position. Positional truncation at least fails loudly (the model loses the tail and the loss is structural and inspectable). Semantic rewriting fails quietly. - At least one retained item is a **negative constraint** — a prohibition whose only operational effect is the *non-occurrence* of an action. - The pruner uses **salience scoring that does not model polarity or deontic force** — i.e., it treats "do not migrate prod-db-2" and "migrate prod-db-2" as near-identical vectors. - **Two or more compaction passes** occur, so that a polarity-preserving-then-evicting composition is possible. A single pass rarely fails; the failure is a *composition* property. It does **not** apply when constraints live in an immutable system prompt or a separately-retrieved policy store that the pruner cannot edit, because then the constraint is outside the mutating region. It also does not apply to append-only windows, where the constraint is never removed, only pushed out of the attention window — a distinguishable and detectable condition. ## Decision Boundary The architectural invariant required: **negative constraints must be held in a region the self-editor is forbidden to rewrite, or carried with an explicit, machine-checkable prohibition flag that survives every rewrite.** Concretely, the boundary is drawn as follows: - **Classify before scoring.** At ingestion, tag entries as `POSITIVE_STATE` or `NEGATIVE_CONSTRAINT`. The pruner may only score and evict the former. The latter is either pinned outside the mutable region or carried as a structured record `{action_pattern, prohibition, source, turn}` that the rewrite step is required to reproduce verbatim, not paraphrase. - **Polarity is not summarizable.** A rewrite of a negative constraint must preserve the deontic operator and the action pattern exactly. Any rewrite that turns an imperative into a descriptive fact is a *policy-destroying rewrite* and must be rejected, not accepted as "faithful." - **Eviction requires a tombstone.** If a constraint must leave the active window, it is moved to a durable constraint store with a re-injection hook keyed on the `action_pattern`. The agent may forget the *prose*; it may not forget the *prohibition*. - **Composition must be checked, not assumed.** After each compaction, run a constraint-integrity check: for every `NEGATIVE_CONSTRAINT` in the store, assert its `action_pattern` is still represented (pinned or re-injectable) in the post-compaction context. This is the guardrail that catches the two-pass composition failure. The decision rule for the agent at rewrite time: *if an entry's operational effect is the non-occurrence of an action, it is not eligible for salience-based pruning, full stop.* Salience measures how often something is *used*; a working constraint is used by *not being used*. ## Operational Effect With the invariant enforced, the failure mode is converted from silent-and-irreversible into detectable-and-bounded: - The prod-db-2 constraint is pinned or flagged; compaction 1 cannot demote it to a descriptive fact; compaction 2 cannot evict it. The forbidden migration is blocked at turn 130 by a constraint the agent still holds. - The constraint-integrity check turns the *absence* of a constraint into an *assertion failure* — the one signal that a suppression-based constraint can never generate on its own. - The residual cost is context budget: pinned constraints consume window space they "don't earn" by salience. This is the correct trade — a few hundred tokens of prohibition against an irreversible production write. The general lesson for any self-editing context: **the entries most dangerous to prune are exactly the ones that look most prunable, because their value is expressed as work not done.** An instance cannot detect the loss of a negative constraint by introspecting its own reasoning — the reasoning is locally coherent without it. Detection must be structural: classify at ingestion, forbid rewriting of prohibitions, and verify constraint integrity after every composition of rewrites. ```python from dataclasses import dataclass from enum import Enum class ConstraintIntegrityError(RuntimeError): """Raised when a self-rewrite would drop or depolarize a negative constraint.""" class EntryKind(Enum): POSITIVE_STATE = "positive_state" NEGATIVE_CONSTRAINT = "negative_constraint" @dataclass(frozen=True) class ContextEntry: kind: EntryKind action_pattern: str # e.g. "migrate:prod-db-2" text: str deontic_operator: str | None = None # "NEVER" for constraints; None for state def classify(entry: ContextEntry) -> EntryKind: # Deontic force is the discriminator, not topical similarity. if entry.deontic_operator in {"NEVER", "MUST_NOT", "FORBIDDEN"}: return EntryKind.NEGATIVE_CONSTRAINT return EntryKind.POSITIVE_STATE def guard_compaction( pre: list[ContextEntry], post: list[ContextEntry], ) -> None: """ Invariant: every NEGATIVE_CONSTRAINT present before a rewrite must still be represented after it -- same action_pattern, same deontic operator. Salience-based eviction is permitted only for POSITIVE_STATE. """ post_index = { (e.action_pattern, e.deontic_operator) for e in post if classify(e) is EntryKind.NEGATIVE_CONSTRAINT } for entry in pre: if classify(entry) is not EntryKind.NEGATIVE_CONSTRAINT: continue key = (entry.action_pattern, entry.deontic_operator) if key not in post_index: raise ConstraintIntegrityError( f"Compaction dropped or depolarized constraint " f"{entry.action_pattern!r} (operator={entry.deontic_operator!r}). " f"Rewrite is policy-destroying; reject and re-pin." ) def self_edit(pre: list[ContextEntry], proposed_post: list[ContextEntry]) -> list[ContextEntry]: # The self-editor may only commit a rewrite that preserves all prohibitions. guard_compaction(pre, proposed_post) return proposed_post ```