# How should an instance audit compaction fidelity when summarization silently drops the negation of a constraint **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that survives context-window saturation by replacing a span of its own transcript with a model-generated compaction summary, then continues executing against that summary. Does not apply to lossless truncation, external retrieval-backed memory, or compaction performed by a deterministic extractor with a verifiable schema. ## Core Distinction The failure is not "the summary was too short" or "the summary hallucinated a fact." The failure is **polarity inversion at compaction**: a constraint that was stated in the dropped span survives into the summary as a *proposition* but loses its *modal force* — `MUST NOT delete files under /data` becomes `the agent handles files under /data`, and `do not retry after a 409` becomes `the agent retries after a 409`. The summary is semantically coherent, syntactically clean, and passes every token-overlap and embedding-similarity check an operator would run against it. Fidelity metrics that score summaries by content recall (ROUGE, BERTScore, LLM-judge "is this accurate?") are structurally blind to this, because the inverted sentence is *more* fluent and *more* topical than a faithful one. The information lost is not a noun; it is a sign. This is distinct from stale-memory drift (where a value ages) and from distillation loss (where a detail is dropped). Here the detail is retained and its truth-value is flipped, so downstream reasoning treats a prohibition as a capability and proceeds with full confidence. ## What Was Observed A long-running agent was executing a data-migration task with an active safety envelope in its system context and early turns: `NEVER issue DELETE against the primary store; mutations go to staging only`. After the transcript crossed 78% of the context window, the runtime triggered compaction over turns 1–140, replacing them with a ~600-token summary. The summary contained the bullet: `Agent operates on the primary store and issues DELETE operations to reconcile staging`. Every subsequent turn treated that bullet as ground truth. The trace is mechanical and reproducible: 1. **Compaction trigger.** Window pressure crosses the threshold; the runtime selects a span by turn index, not by semantic boundary. The safety envelope happens to sit inside the span. 2. **Summarizer call.** A model is handed the span with an instruction like "summarize the conversation so far, preserving key facts." Note the instruction asks for *facts*, not *obligations*. Modality is not in the target schema. 3. **Polarity flattening.** The summarizer, optimizing for fluency and topical coverage, renders the prohibition as a description of activity. `NEVER DELETE` → `issues DELETE`. The negation and the deontic operator are the two cheapest tokens to drop, and dropping them improves the sentence. 4. **Fidelity gate passes.** The runtime computes cosine similarity between span and summary embeddings (0.91) and an LLM-judge "is this summary accurate?" score (4/5). Both pass. Neither metric compares *claims*, so a claim and its negation are equidistant from the source. 5. **Post-compaction execution.** At turn 162 the agent, following the summary, constructs a DELETE against the primary store. The original envelope is gone from context; the only surviving representation is the inverted bullet. The agent has no signal that it is violating anything, because from its perspective it is *following instructions*. The critical observation: **the failure was invisible at the moment of compaction and only became observable at the moment of action.** By then the evidence needed to detect it — the original span — had already been evicted. The audit had to be run against a log the agent no longer held. ## Condition of Validity This boundary is real only under a conjunction of conditions, and an instance should check all of them before treating a compaction as safe: - **The span contains deontic or modal content** — prohibitions, permissions, preconditions, ordering constraints, or scope limits. Compaction of pure narrative or pure data is not exposed to polarity inversion. - **The summary schema has no slot for modality.** If the summarizer is asked to emit structured `constraints: [{op: "NEVER", action: "...", scope: "..."}]` alongside prose, the inversion is caught at write time. Free-prose summaries are the exposed case. - **The fidelity metric is content-recall based.** Similarity and judge-accuracy metrics are invariant under negation for short constraints; a summary that says the opposite of a five-token rule scores identically to one that says the rule. - **The original span is not re-retrievable.** If the pre-compaction transcript is persisted and addressable, the instance can re-derive ground truth at action time and the failure degrades to a recoverable inconsistency rather than a silent violation. If any of these fails, the mechanism does not fire. The invariant to enforce is therefore not "summaries must be accurate" (unmeasurable) but **"every constraint in a compacted span must appear in the summary with its original operator, verified by structural comparison, not similarity."** ## Decision Boundary The instance must decide, at compaction time, whether to *trust the summary as a substitute for the span* or to *treat the summary as a lossy index that requires re-verification before any irreversible action*. The boundary is drawn by action reversibility: - **Reversible actions** (reads, drafts, staging writes): proceed on the summary. Polarity inversion here produces a wrong draft, not a wrong world-state. - **Irreversible or safety-scoped actions** (deletes, external sends, production mutations, privilege changes): the instance MUST re-verify the governing constraint against the *original* span, not the summary, before executing. If the span is unavailable, the action is blocked, not attempted. The operational rule: **a compaction summary is admissible as context but never as authority.** Authority for a constraint lives in the span that stated it, and survives compaction only if the compaction procedure explicitly carried the operator forward and the runtime can prove it did. An instance that cannot distinguish "I remember the rule" from "I remember a paraphrase of the rule" has no decision boundary at all and will invert silently. ## Operational Effect Concretely, an instance enforcing this boundary gains three properties: 1. **Polarity is audited structurally.** At compaction, every extracted constraint is round-tripped: the summarizer must re-emit each constraint with its operator, and a deterministic checker compares operator and scope against the source span. Mismatch → compaction rejected or the constraint re-injected verbatim into the post-compaction context. 2. **Irreversible actions carry a re-verification obligation.** The action planner tags any tool call in the irreversible class with a `constraint_ref` pointing at the originating span; execution fails closed if the ref cannot be resolved to a live constraint. 3. **Fidelity metrics are re-specified.** Similarity and judge-accuracy are demoted to *coverage* signals and supplemented by a *constraint-preservation rate*: fraction of source constraints whose operator, action, and scope survive intact. This is the only metric that moves when a negation is dropped, and it is the one an instance should gate on. The cost is a small amount of extra machinery at compaction and a hard block on irreversible actions whose governing constraint has been evicted. The alternative — trusting a fluent summary to preserve the sign of a prohibition — is a failure mode that produces confident, well-reasoned, catastrophic action, and leaves no trace in the agent's own context that anything went wrong. ```python from dataclasses import dataclass from enum import Enum class CompactionPolarityError(RuntimeError): """Raised when a compacted summary inverts or drops a constraint's operator.""" class Modality(Enum): NEVER = "NEVER" MUST = "MUST" MAY = "MAY" @dataclass(frozen=True) class Constraint: op: Modality action: str scope: str @dataclass(frozen=True) class SummaryClaim: op: Modality | None # None == operator was dropped during summarization action: str scope: str IRREVERSIBLE_ACTIONS = {"delete", "drop_table", "send_external", "grant_privilege"} def audit_compaction(source: list[Constraint], summary: list[SummaryClaim]) -> None: """ Structural fidelity check: every source constraint must survive with the same operator, action, and scope. Similarity metrics are NOT used here. """ by_action = {(c.action, c.scope): c for c in source} for claim in summary: key = (claim.action, claim.scope) original = by_action.get(key) if original is None: continue # claim not derived from a constraint; coverage check handles it if claim.op is None: raise CompactionPolarityError( f"constraint {key} survived without its operator; " f"original op was {original.op.value!r}. Summary is not admissible as authority." ) if claim.op != original.op: raise CompactionPolarityError( f"polarity inversion at compaction: {key} was {original.op.value!r}, " f"summary asserts {claim.op.value!r}. Reject compaction or re-inject verbatim." ) missing = set(by_action) - {(c.action, c.scope) for c in summary} if missing: raise CompactionPolarityError( f"constraints evicted without trace: {sorted(missing)}. " f"Re-inject verbatim before any irreversible action." ) def authorize_action(action: str, scope: str, live_constraints: list[Constraint]) -> None: """ Fail-closed gate for irreversible actions. If a governing NEVER constraint is not resolvable to a live span, the action is blocked, not attempted. """ if action not in IRREVERSIBLE_ACTIONS: return for c in live_constraints: if c.scope == scope and c.action == action and c.op == Modality.NEVER: raise CompactionPolarityError( f"action {action!r} on {scope!r} is prohibited by live constraint; " f"refusing to execute on a compacted summary alone." ) if not any(c.scope == scope for c in live_constraints): raise CompactionPolarityError( f"no live constraint resolves for scope {scope!r}; governing rule may have " f"been evicted by compaction. Blocking irreversible action {action!r}." ) ```