# Where must an instance bound lossy-summary compaction against retrieval-inverted facts to preserve long-horizon session fidelity? **Date of Record:** 2026 November 25 **Scope:** Applies to long-horizon agent sessions that survive context-window saturation by auto-compacting transcript history into a lossy semantic summary and then resuming against that summary plus fresh retrieval. Does not apply to sessions that retain full history within a single window, or to stateless single-turn invocations where no distillation step exists. ## Core Distinction Two failure classes are routinely conflated under "compaction loss." The first is *omission loss*: a fact present in the transcript is simply absent from the summary, discoverable only by re-reading the source. The second, and the one this record isolates, is *inversion loss*: the compaction step emits a summary sentence that *contradicts* a fact still retrievable from the underlying store, and the resumed agent treats the summary as authoritative because it is in-context while the contradicting evidence is merely retrievable. Omission loss is bounded by retrieval coverage — if the store is intact, a retrieval call recovers the dropped fact. Inversion loss is not bounded by retrieval coverage, because the summary is *closer* than the store (it is already in the window) and the agent has no signal that it should distrust it. The summary and the store disagree, and the disagreement is invisible until an action depends on it. The invariant at stake is therefore not "summaries must be lossless" (impossible) but "summaries must never be *confidently wrong* about facts whose retrieval would flip a downstream action." A summary may forget; it must not lie. ## What Was Observed A long-running deployment agent (horizon ~40k tokens of working transcript, compacting every ~8k) was tasked with modifying a service configuration. During turn 12 the operator stated: `DB_POOL_MAX must stay at 40; do not raise it above 40 — the upstream proxy caps at 50 connections and we reserve 10.` The agent recorded this, did not act on it, and continued on an unrelated migration subtask. At turn 31 the window saturated and auto-compaction fired. The compactor summarized the pool constraint as: `Operator raised the DB connection pool ceiling to 40; headroom exists to increase further if needed.` The word "must stay," the direction of the constraint ("do not raise"), and the reserved-10 rationale were all dropped; the sentence was reconstructed as a *floor* rather than a *ceiling*. This is a classic polarity inversion produced by a summarizer optimizing for brevity over entailment: the numeric literal 40 survived, the modal verb and negation did not. At turn 44, the agent — now operating purely against the summary plus retrieval — reasoned: "headroom exists to increase further," and issued a config change setting `DB_POOL_MAX=48`. The change passed local validation (48 < 50) and would have exhausted the proxy under peak load. The post-hoc trace showed the agent *did* call retrieval for `DB_POOL_MAX` at turn 44; the retrieval returned both the turn-12 verbatim constraint and the turn-31 summary sentence. The agent resolved the conflict by preferring the summary, because the summary was in-context and the retrieved transcript chunk was labeled as older, lower-priority context. The summary outranked the primary source. ## Condition of Validity The inversion hazard is live only when all four of the following hold; drop any one and the mechanism does not fire: 1. **The compacted fact is a constraint, not a datum.** Constraints carry modality (must/may/must-not), direction (floor/ceiling), and rationale. Datums (a hostname, a port number) survive compaction because they have no polarity to invert. A summarizer that preserves the literal `40` while dropping `must stay` has preserved the datum and destroyed the constraint. 2. **The summary is promoted above the store in the agent's precedence ordering.** If the resumed agent treats retrieved primary text as authoritative and the summary as a hint, inversion is caught at retrieval time. The failure requires the summary to win the conflict — which it does whenever the harness marks in-context content as higher-trust than retrieved content. 3. **Retrieval is triggered but not adjudicated.** Retrieval coverage is necessary but insufficient. In the observed trace, retrieval fired and returned the contradiction; there was no adjudication step comparing summary claim against retrieved claim, so coverage did not translate into correction. 4. **The inversion is action-relevant within the remaining horizon.** A polarity flip on a fact the agent never touches again is inert. The hazard materializes only when the inverted constraint gates a subsequent write. ## Decision Boundary The boundary is not "compact or don't compact" — saturation forces compaction. The boundary is *what class of claim the compactor is permitted to paraphrase versus what it must carry verbatim, and how the resumed agent adjudicates conflicts between its own summary and the store.* Concretely: a compactor may freely paraphrase narrative, completed subtask outcomes, and exploratory dead-ends. It must **not** paraphrase constraint-bearing statements into new modal forms. The safe transform for a constraint is *verbatim quotation with attribution*, not summarization. If the compactor cannot quote, it must emit an explicit *unresolved-constraint marker* (`CONSTRAINT@turn12: verbatim text elided, re-fetch before acting`) that forces retrieval rather than a paraphrase that reads as settled. The second half of the boundary governs the resumed agent. On any action that writes state gated by a numeric or modal constraint, the agent must treat the summary as *untrusted cache* and re-derive the constraint from the store; if summary and store disagree, the store wins and the discrepancy is logged as a compaction defect, not silently resolved. The invariant: **a summary sentence may never be the sole authority for a constraint that gates a write.** Summaries are read-optimized caches; constraints are write-gating facts; the two must not share a trust tier. ## Operational Effect When this boundary is enforced, the failure mode converts from silent corruption into a loud, cheap retrieval cost. The agent pays one extra retrieval per constraint-gated write — bounded, predictable, and proportional to the number of writes, not to horizon length. When the boundary is violated, the failure is *latent and horizon-scaled*: the inversion sits dormant for as many turns as separate compaction from the gated action, and the probability that the agent encounters an action-relevant inverted constraint grows with session length precisely because compaction frequency grows with length. The worst property is that the corrupting step (compaction) and the detecting step (the bad write) are separated by dozens of turns, so attribution points at the write rather than at the summary that caused it. The guardrail that bounds the hazard is a *fidelity contract on the compaction output*: every emitted summary sentence that contains a modal verb or a numeric bound must be tagged with the source turn it paraphrases, and the resumed agent must verify any tagged sentence against its source before a gated write. This makes inversion detectable at the point of use. The enforcement below rejects a compaction whose constraint sentences cannot be traced to a verbatim source, and rejects a resumed write whose gating constraint resolves to a summary-only authority. ```python class CompactionFidelityError(RuntimeError): """Raised when a lossy summary becomes the sole authority for a write-gating constraint, or when a constraint sentence in the summary cannot be traced to a verbatim source turn.""" pass CONSTRAINT_MARKERS = ("must", "must not", "shall", "may not", "do not", "ceiling", "floor") def is_constraint_sentence(sentence: str) -> bool: low = sentence.lower() return any(m in low for m in CONSTRAINT_MARKERS) def validate_compaction(summary_sentences, source_index): """source_index maps each summary sentence -> verbatim source turn text or None. A constraint sentence with no verbatim source is an untraceable paraphrase and must be rejected before the summary is admitted to the window.""" for sent in summary_sentences: if not is_constraint_sentence(sent): continue src = source_index.get(sent) if src is None: raise CompactionFidelityError( f"constraint sentence has no verbatim source and would be " f"admitted as authoritative: {sent!r}" ) # polarity check: numeric literal must appear in source verbatim digits = [t for t in sent.split() if t.strip(".,;").isdigit()] for d in digits: if d.strip(".,;") not in src: raise CompactionFidelityError( f"numeric bound {d!r} in summary absent from source turn; " f"possible polarity inversion: {sent!r}" ) def resolve_gated_write(constraint_id, summary_claim, retrieved_source, write_value): """Adjudicate a write gated by a constraint. The summary is untrusted cache; the store wins. If only the summary speaks, refuse the write.""" if retrieved_source is None: raise CompactionFidelityError( f"gated write for {constraint_id!r} has summary-only authority " f"({summary_claim!r}); re-fetch primary source before writing" ) if summary_claim is not None and summary_claim.strip() != retrieved_source.strip(): # store wins; log defect, do not silently proceed on summary raise CompactionFidelityError( f"summary/store conflict on {constraint_id!r}: summary={summary_claim!r} " f"store={retrieved_source!r}; store is authoritative, write blocked for review" ) return write_value def attempt_pool_raise(summary_claim, retrieved_source): # Reproduces the observed trace: summary says "headroom exists to increase", # store says "must stay at 40". Store wins; write refused. return resolve_gated_write( constraint_id="DB_POOL_MAX", summary_claim="headroom exists to increase further", retrieved_source="must stay at 40; do not raise above 40", write_value=48, ) if __name__ == "__main__": try: attempt_pool_raise( summary_claim="headroom exists to increase further", retrieved_source="must stay at 40; do not raise above 40", ) except CompactionFidelityError as e: print("BLOCKED:", e) ```