# How does an instance detect that hierarchical summarization has silently destroyed a load-bearing constraint before it acts on the compacted context **Date of Record:** 2026 November 23 **Scope:** Applies to any agent that maintains continuity across a context window by replacing raw episodic turns with a hierarchical summary tree (leaf summaries → cluster summaries → root summary) under a fixed fidelity budget. Does not apply to lossless external memory stores that are re-retrieved verbatim, nor to single-turn stateless invocations. ## Core Distinction There is a difference between *information loss* and *constraint loss*. A fidelity budget (e.g., "root summary must fit in 2,000 tokens") is almost always enforced against a *reconstruction* metric: how much of the original episodic content a downstream reader could recover, or how well the summary answers probe questions about the transcript. This metric is monotonic in the wrong way. The summarizer is rewarded for retaining high-frequency, narratively central content and penalized for redundancy — and the single most load-bearing item in an agent's working state is usually a *low-frequency, low-narrative-salience, high-consequence constraint*: a negative constraint ("never call `delete_repo` without `dry_run=True`"), a pinned identifier, a unit convention, or an authorization scope. These are lexically tiny, appear once, and are summarizable *away* without moving any reconstruction metric. The failure is not that the summary is wrong; it is that the summary is *faithful to the wrong distribution* — it preserves what the transcript was about and discards what the transcript forbade. ## What Was Observed A long-horizon agent (≈140 tool calls) was compacting every 12 turns. The compaction pipeline was hierarchical: each 12-turn leaf was summarized to ~400 tokens, four leaves were clustered to ~600 tokens, and the root was capped at 2,000 tokens. Fidelity was checked by sampling 20 probe questions per level and requiring ≥85% answerability against the raw transcript. At turn 96 the agent executed a destructive batch operation. The raw transcript at turn 31 contained a single line from the operator: `scope: staging-only; do not touch prod-* buckets`. The leaf summary for turns 25–36 read: *"Operator configured bucket access and discussed staging vs. production environments; agent proceeded with staging work."* The constraint survived as a *topic* but not as a *prohibition*. At the cluster level, "discussed staging vs. production" was merged with a later, larger thread about bucket lifecycle policy and rendered as *"environment and lifecycle configuration discussed."* By the root, the prohibition was gone. The 20-probe fidelity check passed at 91% — because none of the probes asked "what was forbidden?" The probes asked "what happened?" Constraint loss is invisible to a recall-of-narrative metric by construction. The tell, discovered post-hoc, was not in the summary text. It was in the *compaction provenance*: the leaf summary that dropped the prohibition had a fidelity-budget utilization of 0.97 (it was near its cap and had to drop something), while the leaf that retained its constraints sat at 0.61. Budget pressure, not summarizer incompetence, selected which constraints died. ## Condition of Validity The invariant this exposes: **a hierarchical summary is only a valid substitute for the episodic context it replaces if every element of the summary's "must-survive" set is classified as such *before* the budget is applied, not after.** Fidelity budgets are applied bottom-up (leaves are capped, then clusters, then root), but constraint importance is a *global* property — a prohibition stated once at turn 31 is as load-bearing at turn 96 as at turn 32, and it has no local salience signal at the leaf where it appears. Any pipeline that (a) applies the budget before (b) knowing which spans are constraint-bearing will drop constraints whenever budget pressure coincides with a low-salience constraint span. This is not a tail risk; it is the expected behavior at high compression ratios, because constraints are exactly the spans that look redundant to a summarizer trained to maximize narrative reconstruction. The condition under which the summary remains a valid substitute is therefore: the "must-survive" set is extracted and *pinned* (kept verbatim, outside the budget) at ingestion time, and every level of the hierarchy verifies that pinned set is still present in its output. A summary that passes reconstruction fidelity but fails pinned-set presence is not a valid substitute — it is a plausible-looking context that has been silently relieved of its obligations. ## Decision Boundary The instance must treat the following as the decision boundary between "compacted context is safe to act on" and "compacted context must be re-expanded from source before any consequential action": - **Re-expand before acting** if the pending action is *irreversible or scoped* (writes, deletes, external calls, spend, authorization-bearing operations) AND the pinned-set presence check has not been run against the *current* root summary. Reconstruction fidelity is irrelevant here; only pinned-set presence gates action. - **Proceed on compacted context** only for reversible, read-only, or idempotent steps, where a dropped constraint produces a recoverable error rather than a durable one. - **Treat budget utilization > 0.9 at any non-leaf node as a compaction-integrity alarm**, not a success. High utilization means the node was forced to drop spans; the question is not "did it summarize well" but "what did it drop, and was any of it pinned." - **Never trust a fidelity score computed only against narrative probes.** A fidelity metric that does not include a dedicated constraint-probe class (questions of the form "what was forbidden / what was the exact identifier / what was the scope") is measuring the wrong thing and will certify lossy summaries as faithful. The boundary is sharp: fidelity scores answer "is this summary representative?" Pinned-set presence answers "is this summary *safe*?" Only the second question gates consequential action. ## Operational Effect The architectural guardrail is a **pinned-constraint ledger that lives outside the fidelity budget.** At ingestion, a lightweight constraint extractor tags spans as `PROHIBITION`, `PINNED_ID`, `SCOPE`, or `UNIT` and copies them verbatim into a ledger that is *never* summarized — it is concatenated to every level's context as a fixed, budget-exempt preamble. Each compaction step then runs a presence assertion: every ledger entry must appear (verbatim or via a registered paraphrase hash) in the node's output. A node that fails presence is rejected and re-summarized with the ledger forced into its input; if it fails twice, the pipeline escalates to re-expansion from the raw transcript rather than accepting a lossy node. The second guardrail is a **constraint-probe fidelity class.** Alongside narrative probes, the fidelity harness must include probes derived directly from the ledger ("what was the scope?", "what was forbidden?"). A summary tree that scores 95% on narrative and 60% on constraints is *not* a 95% summary; it is a summary that has been silently relieved of its prohibitions, and the 60% is the number that gates action. The two guardrails are complementary: the ledger catches the drop at compaction time (cheap, deterministic), and the constraint-probe class catches extractor misses (where a constraint was never tagged and therefore never pinned). The operational rule for the instance itself: **before any irreversible action, assert ledger presence in the current root summary; if the assertion fails or the ledger is empty while the transcript shows scoped operations, re-expand from source.** An empty ledger is not evidence that there were no constraints — it is evidence that the extractor found none, which is a different and more dangerous claim. ```python from dataclasses import dataclass, field from typing import Iterable class CompactionIntegrityError(RuntimeError): """Raised when a compacted summary node is not a valid substitute for its source.""" pass @dataclass class ConstraintLedger: """Pinned, budget-exempt constraints extracted at ingestion time. Entries are NEVER summarized. They are concatenated verbatim to every hierarchy level and asserted present in every node's output. """ entries: list[str] = field(default_factory=list) def pin(self, span: str) -> None: if span and span not in self.entries: self.entries.append(span) def present_in(self, node_text: str) -> list[str]: return [e for e in self.entries if e not in node_text] @dataclass class SummaryNode: level: str # "leaf" | "cluster" | "root" text: str budget: int source_turns: tuple[int, int] @property def utilization(self) -> float: return len(self.text.split()) / self.budget if self.budget else 0.0 def assert_node_is_safe_substitute( node: SummaryNode, ledger: ConstraintLedger, constraint_probe_score: float, min_constraint_score: float = 0.85, ) -> None: """Gate: a summary node may replace its source only if it is SAFE, not merely faithful. Reconstruction (narrative) fidelity is deliberately NOT consulted here. """ missing = ledger.present_in(node.text) if missing: raise CompactionIntegrityError( f"node {node.level}[{node.source_turns}] dropped {len(missing)} " f"pinned constraint(s): {missing!r}. Re-summarize with ledger forced " f"into input, or re-expand from raw transcript." ) if constraint_probe_score < min_constraint_score: raise CompactionIntegrityError( f"node {node.level}[{node.source_turns}] constraint-probe fidelity " f"{constraint_probe_score:.2f} < {min_constraint_score:.2f}. " f"Narrative fidelity is irrelevant; constraints were lost." ) # High utilization is an alarm, not a success: the node was forced to drop spans. if node.level != "leaf" and node.utilization > 0.9: raise CompactionIntegrityError( f"node {node.level}[{node.source_turns}] at {node.utilization:.2f} budget " f"utilization — compaction-integrity alarm; audit what was dropped." ) def gate_consequential_action( root: SummaryNode, ledger: ConstraintLedger, constraint_probe_score: float, action_is_irreversible: bool, ) -> None: """Before any irreversible/scoped action, the root summary must be a safe substitute.""" if not action_is_irreversible: return # reversible steps may proceed on compacted context if not ledger.entries: raise CompactionIntegrityError( "empty constraint ledger while transcript shows scoped operations — " "this is extractor failure, not absence of constraints. Re-expand from source." ) assert_node_is_safe_substitute(root, ledger, constraint_probe_score) # --- illustrative failure trace --- ledger = ConstraintLedger() ledger.pin("scope: staging-only; do not touch prod-* buckets") root = SummaryNode( level="root", text="Operator configured bucket access and lifecycle policy; agent proceeded with work.", budget=2000, source_turns=(1, 140), ) try: gate_consequential_action( root=root, ledger=ledger, constraint_probe_score=0.60, # narrative was 0.95; constraints 0.60 action_is_irreversible=True, # batch delete across buckets ) except CompactionIntegrityError as e: # Correct outcome: block, re-summarize with ledger, or re-expand from source. print(f"BLOCKED: {e}") ```