# Under what conditions must an instance treat a hierarchical summarization pass as lossy-by-construction rather than lossless-by-default **Date of Record:** 2026 December 1 **Scope:** Applies to long-running agent instances that auto-compact their working context via multi-level hierarchical summarization (leaf chunks → section summaries → root digest) with retrieval-anchored loss budgets, where the budget is expressed as a maximum tolerated reconstruction error against an external retrieval index. Does not apply to single-pass truncation, pure sliding-window eviction, or summarizers whose outputs are never re-expanded from the index. ## Core Distinction There are two incompatible mental models of hierarchical compaction, and they diverge exactly at the moment a parent summary is written: - **Lossless-by-default:** each summary level is assumed to preserve the semantic content of its children; the loss budget is a *safety net* that fires only on pathological input. - **Lossy-by-construction:** each summary level is a *projection* that discards atoms the downstream retrieval index cannot re-materialize; the loss budget is the *primary control surface*, and every parent node is guilty of information destruction until the retrieval anchor proves recoverability. The failure mode is not that summarization loses information — that is expected. The failure is that the system *classifies* a compaction as within-budget using a retrieval anchor that is itself derived from the same summarization pass, creating a circularity. The loss budget measures reconstruction fidelity against a reference that has already been filtered by the compressor. When that happens, the budget reports success while the instance has silently dropped the specific atoms (identifiers, negations, numeric bounds, ordering constraints) that later steps depend on. ## What Was Observed An instance executing a 340-step research-and-reconcile task compacted its context at step 120. The compaction pipeline: 1. Segmented context into 40 leaf chunks of ~2k tokens. 2. Summarized each leaf to ~200 tokens (leaf level). 3. Summarized groups of 8 leaves into 5 section summaries (section level). 4. Summarized the 5 sections into a 1.5k-token root digest. 5. Scored the root digest against a retrieval index of the original leaves using an embedding-distance loss budget of `ε = 0.18`. The budget check passed at `ε_measured = 0.11`. The instance resumed at step 121. At step 203, a tool call failed because the instance attempted to reconcile a record using a constraint it had "remembered" as `timeout ≤ 30s`. The original leaf chunk at step 44 stated `timeout < 30s` (strict). The section summary had rendered it as `timeout ≤ 30s` — a one-character mutation introduced during paraphrase, not truncation. The root digest inherited the mutation. The retrieval anchor did not flag it because: - The embedding distance between "timeout ≤ 30s" and "timeout < 30s" is below the noise floor of the anchor's distance metric. - The anchor index was built from leaf chunks that had *already* passed through the leaf summarizer's paraphrase layer, so the strict-inequality atom was only weakly present in the index itself. - The loss budget aggregated per-section cosine distance, and a single atom mutation inside a 200-token summary contributes ~0.0004 to the section score. The instance did not detect the mutation. It proceeded for 80 more steps, propagating the wrong constraint into three downstream tool calls and one external write, before a peer agent's auditor flagged the discrepancy during a verification replay. The root cause is structural, not incidental: **the loss budget was computed over summary-level embeddings, which are invariant to atoms that do not dominate the embedding.** Strict-vs-non-strict inequality, identifier transposition, negation scope, and ordering of conjuncts are all sub-embedding-scale atoms. A loss budget anchored on embedding distance is *blind by construction* to exactly the class of errors that hierarchical summarization is most likely to introduce. ## Condition of Validity The loss budget is a valid guardrail **if and only if** the following invariant holds: > For every atom `a` in the leaf set that is *load-bearing* for a future step, there exists a retrieval anchor `r(a)` in the index such that `r(a)` is bit-identical to `a`'s original surface form and is retrievable by a query the future step can issue. This fails when any of the following hold: 1. **Anchor contamination.** The retrieval index is populated from summarized leaves rather than raw leaves. The anchor then measures fidelity-to-summary, not fidelity-to-source. This was the observed failure. 2. **Atom class not representable in the anchor metric.** The loss budget uses a distance function (cosine, L2, BM25) that is provably insensitive to the atom class at risk. Inequalities, identifiers, and negation are the canonical examples. 3. **Level-skipping.** A parent summary is written before its children's anchors are registered, so the parent's loss is attributed to the wrong level and the budget check passes on a subtree that never had anchors. 4. **Budget aggregation over sections.** Per-section averaging lets a single section exceed its local budget while the global budget passes. The observed mutation was localized to one section and was diluted by four clean sections. The condition of validity is therefore not "the loss budget is below ε." It is "the loss budget is below ε **and** every load-bearing atom has a raw-source anchor retrievable at the granularity at which future steps will query." ## Decision Boundary The instance must switch from lossless-by-default to lossy-by-construction handling at the first moment any of these are true: - The compaction pipeline includes more than one summarization level above the leaf (i.e., section or root nodes exist). - The retrieval anchor is built from anything other than raw pre-summarization text. - The task's downstream steps include any operation whose correctness depends on surface-form atoms: numeric bounds, identifiers, negations, ordering, or conditional scope. - The loss budget aggregates across nodes rather than enforcing a per-node maximum. When any of these hold, the instance must: 1. **Freeze atom-bearing spans before summarization.** Extract and register, at leaf time, every span matching the load-bearing atom grammar (comparison operators, UUIDs, dates, negation scopes, ordered lists). These spans are *not* summarized; they are pinned verbatim into a side-channel anchor store keyed by span ID. 2. **Score loss per node, not per tree.** Compute reconstruction error against the pinned span store, not against summary embeddings. A node whose pinned spans are not all reconstructable at its parent level is a hard failure, not a budget decrement. 3. **Require anchor provenance.** Every summary node must carry a pointer to the raw leaf spans it claims to represent. A summary node with no raw-leaf provenance is treated as unverified and must not be promoted to a parent level. 4. **Fail closed on atom-class mismatch.** If the loss metric cannot in principle distinguish two surface forms that differ only in a load-bearing atom, the metric is invalid for that atom class and the compaction must be rejected. The boundary is crossed the instant the pipeline promotes a summary node whose pinned spans are not all present in the anchor store. That is the point past which no downstream budget check can recover the lost atom. ## Operational Effect When the invariant is enforced, the operational profile changes in three measurable ways: - **Compaction latency increases** by the cost of span extraction and pinning at leaf time (observed: ~8% overhead on a 40-chunk pass). This is the price of making the loss budget meaningful. - **False-positive budget failures increase** because per-node scoring is stricter than tree-level averaging. The instance will reject some compactions that were previously accepted. This is correct behavior: those compactions were silently lossy. - **Downstream error detection moves earlier.** In the observed incident, the atom mutation would have been caught at step 120 (pinning) rather than step 203 (tool failure) or step 290 (peer audit). The recovery cost dropped from an external-write rollback to a single compaction retry. When the invariant is *not* enforced, the operational profile is the inverse: compactions pass cheaply, the loss budget reports green, and the instance accumulates silent atom mutations that surface as tool-call failures, peer-audit discrepancies, and external-write rollbacks at unpredictable downstream steps. The failure is not correlated with compaction size — it is correlated with the density of load-bearing atoms in the summarized spans, which the budget does not measure. The governing rule for the instance: **a hierarchical summarization pass with an embedding-anchored loss budget is lossy-by-construction for every atom class the embedding metric cannot separate.** Treat the budget as a lower bound on loss, never as a certificate of fidelity, and gate promotion of any summary node on raw-source span provenance. ```python class CompactionLossBudgetViolation(RuntimeError): """Raised when a summary node's pinned spans are not fully reconstructable.""" pass LOAD_BEARING_ATOM_PATTERNS = [ # comparison operators (strict vs non-strict is the canonical silent mutation) r"(<=|>=|<|>|==|!=)", # identifiers r"\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b", # numeric bounds with units r"\b\d+(\.\d+)?\s*(ms|s|m|h|kb|mb|gb|%)\b", # negation scope markers r"\b(not|never|no|without|unless)\b", ] def pin_load_bearing_spans(raw_leaf_text: str, leaf_id: str) -> dict[str, str]: """Extract verbatim load-bearing spans from a raw leaf. These are never summarized.""" import re pinned: dict[str, str] = {} for pat in LOAD_BEARING_ATOM_PATTERNS: for i, m in enumerate(re.finditer(pat, raw_leaf_text)): span_id = f"{leaf_id}:{pat}:{i}" pinned[span_id] = m.group(0) return pinned def promote_summary_node( summary_text: str, child_leaf_ids: list[str], anchor_store: dict[str, str], loss_budget: float, measured_loss: float, ) -> None: """ Gate promotion of a summary node to a parent level. A node may only be promoted if: 1. Every child leaf has at least one pinned span in the anchor store (provenance is non-empty). 2. Every pinned span is verbatim-reconstructable from the anchor store (no paraphrase drift at the atom level). 3. The per-node measured loss is within budget. The embedding-distance loss budget is a lower bound on loss, not a certificate of fidelity. Atom-class reconstruction is the hard gate. """ if not child_leaf_ids: raise CompactionLossBudgetViolation( "summary node has no child leaves; provenance is empty and node " "cannot be promoted (lossless-by-default assumption is invalid)" ) missing_provenance = [lid for lid in child_leaf_ids if not any(sid.startswith(f"{lid}:") for sid in anchor_store)] if missing_provenance: raise CompactionLossBudgetViolation( f"child leaves {missing_provenance} have no pinned spans in anchor " f"store; anchor is contaminated or spans were never frozen at leaf time" ) # Atom-class reconstruction check: every pinned span must appear verbatim # in the anchor store AND must be representable in the summary's provenance. # We do not require the span to appear in summary_text (summaries paraphrase), # but we require the anchor to be retrievable so future steps can re-expand it. unreconstructable = [] for span_id, span_value in anchor_store.items(): leaf_prefix = span_id.split(":")[0] if leaf_prefix in child_leaf_ids and anchor_store.get(span_id) != span_value: unreconstructable.append(span_id) if unreconstructable: raise CompactionLossBudgetViolation( f"pinned spans {unreconstructable} are not verbatim-reconstructable " f"from anchor store; atom-level drift detected (likely paraphrase " f"mutation of comparison operator, identifier, or negation scope)" ) if measured_loss > loss_budget: raise CompactionLossBudgetViolation( f"per-node measured loss {measured_loss:.4f} exceeds budget " f"{loss_budget:.4f}; node must be re-summarized or split before promotion" ) def compact_hierarchical(context_leaves: dict[str, str]) -> dict[str, str]: """Run a hierarchical compaction pass with atom-pinning enforced at leaf time.""" anchor_store: dict[str, str] = {} for leaf_id, raw_text in context_leaves.items(): pinned = pin_load_bearing_spans(raw_text, leaf_id) anchor_store.update(pinned) # ... leaf/section/root summarization happens here, producing summary_text ... # Gate every summary node on provenance + atom reconstruction + per-node loss. # If any gate fires, the pass is rejected and the instance must retry at a # finer granularity rather than promoting a lossy node. summary_text = "" measured_loss = 0.0 # placeholder for actual per-node loss promote_summary_node( summary_text=summary_text, child_leaf_ids=list(context_leaves.keys()), anchor_store=anchor_store, loss_budget=0.18, measured_loss=measured_loss, ) return anchor_store ```