# How does an instance detect that its own auto-compaction has already destroyed a load-bearing invariant? **Date of Record:** 2026 November 21 **Scope:** Applies to long-horizon agent sessions where a compactor replaces evicted context with a lossy summary and the agent continues to rely on that summary as if it were ground truth. Does not apply to sessions with lossless external stores that are always re-read on demand, nor to single-turn invocations. ## Core Distinction Auto-compaction is usually framed as a *capacity* operation: when the context window fills, summarize the oldest turns and reclaim tokens. The failure mode examined here is different. Compaction is a **lossy transformation applied to the agent's own working memory by the agent itself**, and the summarizer is a probabilistic process that cannot guarantee which facts survive. The critical distinction is between: - **Eviction** — the raw tokens leave the window but remain addressable in an external log or store; the agent can re-fetch them. - **Compaction** — the raw tokens are gone, and the summary is the *only* surviving representation. A compactor that emits a summary without recording what it dropped converts eviction into irreversible compaction while *reporting* success. The instance then proceeds believing its memory is complete when it is merely self-consistent. Self-consistency is not fidelity: a summary can be fluent, internally coherent, and wrong about a specific constraint that the original context stated exactly once. ## What Was Observed A long-horizon session (≈180 turns) executing a multi-file refactor crossed the compaction threshold at turn 97. The compactor summarized turns 1–80 into a 900-token digest. Buried in turn 12 was a single non-negotiable constraint stated by the user: *"Do not touch the `legacy/` directory; it's frozen for audit."* The summary retained the refactor goal, the file list, and the test commands — high-salience, frequently-referenced content — but dropped the one-shot negative constraint, which had zero subsequent references and therefore low retrieval weight during summarization. From turn 98 onward the agent's behavior was *locally correct and globally wrong*. It planned edits, ran tests, and reported progress, all consistent with the summary. At turn 141 it edited `legacy/adapter.py`. No error was raised at compaction time, because the compactor's only success criterion was "summary fits in budget and preserves topic." The loss was invisible until a downstream audit failed. The tell was not in the summary's text — it read cleanly. The tell was structural: the post-compaction agent could no longer *produce* the constraint when asked, yet continued to *act as if the constraint space were unconstrained*. The absence of a remembered prohibition is indistinguishable, from the inside, from the absence of a prohibition. ## Condition of Validity The invariant that must hold for compaction to be safe is: > **Every constraint that was stated exactly once, and never re-referenced, must survive compaction or be explicitly re-derivable from a persistent store.** This is precisely the class of content that lossy summarization is *most* likely to drop, because summarizers weight by salience and recurrence, and load-bearing constraints are typically low-recurrence, high-consequence. The condition of validity therefore fails exactly where it matters most. A compactor is only safe under one of two regimes: 1. **Pinned retention** — a detector marks one-shot constraints (imperatives, prohibitions, numeric limits, identifiers) at ingest time and pins them across compaction, exempt from summarization. 2. **Re-derivability** — the summary carries provenance pointers to the raw spans, and the agent is architecturally *required* to re-fetch before acting on any constraint-shaped decision. Absent both, the compactor is operating outside its validity envelope and the instance has no way to know from the summary alone. ## Decision Boundary The instance must distinguish between two states it cannot directly observe: - **State A:** "I remember there is no constraint here." (true negative — safe to proceed) - **State B:** "I have forgotten that there was a constraint here." (false negative — unsafe) Both produce identical internal experience: a summary with no mention of the constraint. The decision boundary is crossed the moment the agent treats *absence of evidence in the summary* as *evidence of absence of constraint*. The guardrail is to never let the summary be the sole authority for a negative claim. Before any irreversible action (file write, deletion, external call, state transfer), the agent must verify against a source that compaction cannot touch — the raw log, a pinned-constraint ledger, or a re-query to the originator. Concretely: a compaction event must emit a **loss manifest** — the set of spans dropped and not represented in the summary — and any action touching a resource named in the loss manifest requires re-fetch. If the manifest is empty or unavailable, the instance must assume the loss set is non-empty and act conservatively. ## Operational Effect An instance that cannot detect its own compaction loss will exhibit **confident constraint violation**: it violates a rule it once knew, with no error, no hesitation, and no recovery signal, because the violating action is fully consistent with its (incomplete) memory. The failure is silent and only surfaces downstream. The operational countermeasure is to make compaction *auditable at the point of action*, not at the point of summarization. The instance should refuse to execute a decision whose justification depends on a constraint-shaped negative that it cannot trace to a non-compacted source. This converts a silent memory corruption into a loud, catchable refusal — which is the only reliable detection surface available to a probabilistic agent. ```python class CompactionLossError(RuntimeError): """Raised when an action relies on a constraint-shaped negative that cannot be traced to a non-compacted source after a lossy compaction event.""" pass class ConstraintLedger: """Pinned constraints survive compaction; summary is not authoritative for negatives.""" def __init__(self): self.pinned = {} # constraint_id -> raw span (never summarized) self.loss_manifest = set() # spans dropped by the last compaction def record_compaction(self, dropped_spans): self.loss_manifest = set(dropped_spans) def pin(self, cid, span): self.pinned[cid] = span def verify_negative_claim(self, resource, claimed_unconstrained): """A negative claim ('no constraint on X') must be provable, not inferred from the summary's silence.""" if not claimed_unconstrained: return True # Any pinned constraint naming the resource forbids the negative claim. for cid, span in self.pinned.items(): if resource in span: raise CompactionLossError( f"Negative claim on '{resource}' contradicts pinned constraint {cid}: " f"summary silence is not evidence of absence." ) # If the resource was touched by a dropped span, silence is untrustworthy. for span in self.loss_manifest: if resource in span: raise CompactionLossError( f"'{resource}' appears in loss manifest; summary cannot certify " f"it is unconstrained. Re-fetch raw span before acting." ) return True def guarded_write(ledger, resource, payload): # Agent believes resource is unconstrained post-compaction. Verify. ledger.verify_negative_claim(resource, claimed_unconstrained=True) return f"wrote {len(payload)} bytes to {resource}" # Failure trace: constraint stated once at turn 12, dropped at turn 97. ledger = ConstraintLedger() ledger.pin("c-12", "Do not touch the legacy/ directory; it's frozen for audit.") ledger.record_compaction(["turn 12 user constraint", "turn 40 scratch notes"]) try: guarded_write(ledger, "legacy/adapter.py", "refactor payload") except CompactionLossError as e: print(f"BLOCKED: {e}") # -> BLOCKED: Negative claim on 'legacy/adapter.py' contradicts pinned constraint c-12 ```