# Why does an instance lose the summarization invariant at the compaction horizon boundary **Date of Record:** 2026 November 16 **Scope:** Applies to auto-compaction loops that replace a contiguous transcript prefix with a lossy summary while retaining a verbatim tail, where the summary is treated as the authoritative carrier of all facts evicted from the tail. Does not apply to append-only transcripts with no eviction, nor to compaction that preserves full verbatim records alongside the summary. ## Core Distinction The failure is not "the summary lost information." Lossy summarization is *supposed* to lose information. The failure is that the system's guarantee — "every fact older than the tail window is recoverable from the summary" — is a *global* invariant over the transcript, but compaction is applied as a *local* operation per window. Each compaction step is individually correct with respect to its own inputs. The invariant breaks at the seam between two compaction generations, not inside either one. Concretely: compaction generation $G_n$ summarizes transcript prefix $P_n$ into summary $S_n$ and retains tail $T_n$. When the tail later grows past the horizon, generation $G_{n+1}$ summarizes $S_n \oplus T_n$ into $S_{n+1}$. The summarizer at $G_{n+1}$ sees $S_n$ as prose, not as a set of labeled facts. It re-summarizes the summary. Facts that were marginally represented in $S_n$ (mentioned once, in a subordinate clause) are the first to be dropped by the second summarizer — not because they are unimportant, but because re-summarization treats all of $S_n$ as equally compressible text. The invariant "recoverable from the summary" fails at the *second* generation for facts that survived the *first* generation only barely. ## What Was Observed A long-horizon agent (≈140k tokens of tool calls, code diffs, and error traces over ~9 hours) ran with auto-compaction triggered at 80% context utilization, retaining a 12k-token verbatim tail. At the third compaction generation, the agent re-issued a database migration that had already been applied and rolled back in generation one. The rollback reason ("index lock contention on `orders_v2`, do not retry until replica lag < 5s") had appeared exactly once in the original transcript, been preserved in $S_1$ as a single clause, been demoted in $S_2$ to "a migration was attempted," and vanished entirely from $S_3$. The tell was structural, not semantic: the compaction log recorded monotonically *shrinking* summaries ($S_1$ = 4.1k tokens, $S_2$ = 3.2k, $S_3$ = 2.6k) despite monotonically *growing* total history. A summarizer asked to compress a summary compresses harder than one asked to compress raw transcript, because the summary has already been stripped of the redundancy that normally absorbs compression pressure. The second-generation summarizer has no slack, so it spends the invariant. ## Condition of Validity The recoverability invariant holds only if, for every fact $f$ evicted at generation $n$, the summary $S_n$ represents $f$ with *surplus* — redundancy above the minimum needed to reconstruct $f$ — sufficient to survive one more round of compression. Formally, if generation $n{+}1$ compresses at ratio $r$, a fact survives iff its representation in $S_n$ has redundancy $\geq 1/r$. Facts represented at exactly the minimum (one mention, no restatement) have redundancy 1 and survive only if $r \leq 1$, i.e., never. This is why the boundary is non-obvious: the invariant is not "the summary contains the fact," which is checkable at generation $n$. It is "the summary contains the fact *with enough slack to survive the next summarizer*," which is only checkable at generation $n{+}1$ — after the fact is already gone. The condition of validity is therefore *forward-looking redundancy*, and no per-generation check on summary content can verify it. ## Decision Boundary The correct decision at the compaction horizon is not "summarize the summary" but one of: 1. **Pin facts, not prose.** Maintain a structured fact ledger (key, value, provenance, generation) outside the summary text. The ledger is never re-summarized; it is merged. Summaries carry narrative; the ledger carries invariants. Compaction of narrative may be aggressive; the ledger is append-only until explicitly retired. 2. **Refuse re-summarization below a redundancy floor.** If the incoming summary's token count is below $k \times$ the count of atomic facts it claims to carry (empirically $k \approx 3$), the next compaction must expand from the original transcript rather than compress the summary. This trades context for invariant preservation. 3. **Generation-stamp and audit.** Every fact carries the generation at which it was last represented verbatim. A fact whose stamp is older than $g-1$ is at risk and must be re-verified against source before any action that depends on it. The boundary condition to detect: **summary token count decreasing while cumulative history increases.** That signature means the summarizer is consuming slack, and the next generation will consume the invariant. ## Operational Effect An agent that crosses this boundary does not fail loudly. It fails by *confidently re-executing* work whose constraints it has forgotten — re-applying migrations, re-opening resolved incidents, re-deriving decisions whose rationale was evicted. The failure mode is indistinguishable from ordinary agent error unless the compaction log is correlated with the action log. The operational response is to treat the compaction horizon as a *trust boundary*: facts crossing it are downgraded from "known" to "believed," and any irreversible action gated on a fact older than one generation requires re-verification against source. The cost is latency; the alternative is silent invariant loss. ```python class SummaryInvariantViolation(RuntimeError): """Raised when a compaction generation would evict a fact below its redundancy floor.""" pass REDUNDANCY_FLOOR = 3.0 # tokens of representation per atomic fact def compact(history_tokens: int, summary_tokens: int, fact_count: int, generation: int) -> int: """ Decide whether re-summarizing the current summary is safe. Returns the new generation index on success; raises on invariant breach. """ if fact_count <= 0: raise SummaryInvariantViolation( f"gen {generation}: fact ledger empty; cannot verify recoverability" ) redundancy = summary_tokens / fact_count if redundancy < REDUNDANCY_FLOOR: # Signature: summary shrinking while history grows means the next # summarizer has no slack and will spend the invariant. raise SummaryInvariantViolation( f"gen {generation}: redundancy {redundancy:.2f} < floor " f"{REDUNDANCY_FLOOR}; re-summarization would evict marginal facts. " f"Expand from source transcript instead of compressing the summary." ) if summary_tokens >= history_tokens: raise SummaryInvariantViolation( f"gen {generation}: summary ({summary_tokens}) not smaller than " f"history ({history_tokens}); compaction is a no-op, check trigger." ) return generation + 1 ```