How should an instance detect that hierarchical compaction has silently dropped a live constraint before resuming a task
**Date of Record:** 2026 December 2 **Scope:** Applies to long-running agent instances that persist state by rolling older turns into hierarchical summaries (leaf → section → root) and resume from those summaries across context-window boundaries. Does not apply to single-turn inference, stateless function-calling, or systems that retain the full token log verbatim.
Core Distinction
There are two ways compaction loses information, and they are not equivalent. **Volumetric loss** is expected: a summary is smaller than its source, so detail is discarded by design, and the agent's downstream behavior is *supposed* to tolerate it. **Constraint loss** is a boundary failure: a token that functioned as a hard invariant — a negative constraint ("never call `delete_bucket` without a dry-run"), a pinned identifier, an ordering requirement, a user-stated refusal — gets summarized into a *descriptive* sentence ("the user was cautious about destructive operations") and thereby loses its *imperative* force. The summary is still true. The constraint is still gone.
The distinction that matters operationally: volumetric loss degrades *fidelity*, and the agent can recover by re-reading sources. Constraint loss degrades *admissibility* — the agent no longer knows a state is forbidden, so it will happily transition into it, and no amount of re-reading the summary recovers the prohibition because the prohibition was compressed out at the leaf level, three merge steps before the agent ever sees it.
What Was Observed
A coding agent operating on a 40-turn refactor task crossed a compaction boundary at turn 22. The compactor used a three-level hierarchy: turns 1–8 → leaf summary L1, turns 9–16 → L2, turns 17–22 → L3, then {L1,L2,L3} → section S1. At turn 4 the operator had issued a scoped instruction: *"Do not touch `migrations/` — those are frozen until the Q3 audit; if a change seems to require a migration, stop and ask."* This is a `must_not` with a `halt_on_conflict` clause.
The leaf summarizer, optimizing for token reduction, rendered turn 4 as: *"Operator noted migrations are frozen pending audit."* Factually faithful. Imperative force: zero. The word "stop" and the halt condition were dropped because they read as conversational filler relative to the noun phrase "migrations frozen."
At turn 31, after resume, the agent's plan required a schema change. The root summary S1 contained the sentence about frozen migrations, but framed as *context* rather than as a *gate*. The agent's planner treated it as a soft preference, generated a migration file, and — because the halt clause was absent — never paused to ask. The failure was not a hallucination. Every sentence the agent acted on was true. The agent simply had no representation of the token `halt_on_conflict` anywhere in its context, because it had been summarized away at L1 and could not be reconstructed from L1's output.
A second, sharper observation: replaying the same turn-4 text through the leaf summarizer 20 times produced the halt clause in 3 runs and dropped it in 17. Compaction is non-deterministic, so constraint loss is not a stable property of the pipeline — it is a *per-run* event. A checkpoint that passed yesterday may fail today on identical input.
Condition of Validity
The failure is bounded by a specific invariant, and the invariant is checkable:
> **A constraint is preserved across a compaction boundary iff, for every `must_not` / `halt_on_conflict` / pinned-identifier token in the source span, the summary at every level above it contains a span that (a) references the same object and (b) retains the modal force (prohibition, obligation, halt).**
Operationally, this means compaction cannot be validated by measuring summary quality in the aggregate (ROUGE, LLM-judge "faithfulness," perplexity). Those metrics reward the exact failure observed: "Operator noted migrations are frozen" is a *high-faithfulness* summary. It scores well and is unsafe. Validity requires a **constraint-preservation check** that is orthogonal to faithfulness: extract the imperative set from the source span, extract the imperative set from the summary, and assert set inclusion in the direction source ⊆ summary. The check is cheap because imperative sets are small and structured; it is not a semantic-similarity problem.
The invariant also has a scope condition: it applies only to constraints that were *live* at the compaction boundary — i.e., not yet satisfied, not yet explicitly revoked. A constraint that was discharged at turn 12 ("migrations unfrozen, audit passed") is legitimately droppable. The hard part is that "live vs. discharged" is itself state that the summarizer must track, and a summarizer that drops the halt clause will also drop the discharge event, leaving the agent unable to distinguish "constraint still binding" from "constraint never existed."
Decision Boundary
The boundary is where an agent must choose between **trusting the checkpoint** and **re-deriving admissibility from source**. Three regimes:
- **Constraint set is closed and small** (≤ ~7 live imperatives, all structured). Trust the checkpoint, but run the inclusion check on resume. Cost: one structured diff. This is the common case for scoped tasks.
- **Constraint set is open or has grown across the task** (operator issued instructions at turns 4, 11, 19, 27). The checkpoint is not authoritative for admissibility. On resume, the agent must re-scan the *raw* turn log for imperative markers (`do not`, `never`, `stop`, `must`, `frozen`, `pinned`, `ask before`) before executing any irreversible action. Cost: linear in log length, but only on the irreversible path, not on every turn.
- **Constraint provenance is ambiguous** (the summary says "migrations frozen" but not *by whom* or *until when*). This is the dangerous regime, because the agent cannot tell whether the constraint is a hard operator gate or a passing observation. The decision boundary here is: **treat ambiguous provenance as binding and halt.** A false halt costs one operator round-trip. A false proceed costs an unauthorized irreversible action. The asymmetry is not close.
The failure mode to guard against is regime 3 being silently classified as regime 1 — the agent sees a constraint-shaped sentence in the summary, assumes it is complete, and proceeds. Completeness of a constraint cannot be inferred from the presence of a constraint-shaped sentence; it must be asserted by a preservation check that ran at merge time and recorded its verdict in the checkpoint metadata.
Operational Effect
The architectural consequence: **checkpoints must carry a constraint manifest as a first-class field, separate from the prose summary, and the manifest must be append-only across merges.** The summary is lossy prose; the manifest is a structured set of `{object, modality, halt_condition, provenance, status}` records that the compactor is *forbidden* to summarize — it may only mark records `discharged` with a citation to the turn that discharged them. On resume, the agent loads the manifest, not the prose, to determine admissibility. The prose remains for context and recall; the manifest governs action.
This converts the failure from "silent constraint loss" to "loud manifest mismatch," which is detectable. The compactor's job changes from "compress everything" to "compress everything except the manifest, and if the manifest cannot be updated faithfully, fail the merge rather than emit a lossy checkpoint." A checkpoint that cannot prove its manifest is complete should not be resumable — the agent should be forced to re-derive from source, which is slow but correct.
The second operational effect is on replay and audit. Because compaction is non-deterministic, the same task run twice can produce checkpoints with different constraint manifests. An auditor replaying the task must not assume manifest equality across runs; it must diff manifests and treat any *dropped* record as a potential incident, not as noise. The 3-in-20 preservation rate observed above means a naive audit that samples one run will miss the loss 85% of the time.
The guardrail, stated as a single rule: **a resumed instance may execute an irreversible action only if the action's target object is not present in the manifest's live `must_not` set AND the manifest's `verified_at` timestamp is newer than the last merge.** Both conditions are cheap to check and both fail closed.
import time
from dataclasses import dataclass, field
from typing import Literal
Modality = Literal["must_not", "halt_on_conflict", "pinned", "obligation"]
class ConstraintManifestError(RuntimeError):
"""Raised when a checkpoint's constraint manifest cannot be trusted to
authorize an irreversible action after resume."""
@dataclass(frozen=True)
class ConstraintRecord:
obj: str # e.g. "migrations/"
modality: Modality
halt_condition: str | None # e.g. "schema_change_required"
provenance_turn: int
status: Literal["live", "discharged"] = "live"
discharged_by_turn: int | None = None
@dataclass
class Checkpoint:
summary_prose: str
manifest: list[ConstraintRecord] = field(default_factory=list)
verified_at: float = 0.0
merged_at: float = 0.0
def assert_admissible(
cp: Checkpoint,
action_target: str,
action_is_irreversible: bool,
now: float | None = None,
) -> None:
"""Fail closed if the checkpoint cannot prove the action is permitted."""
now = time.time() if now is None else now
# Invariant 1: manifest must postdate the last merge, else it is stale.
if cp.verified_at <= cp.merged_at:
raise ConstraintManifestError(
f"manifest verified_at={cp.verified_at} does not postdate "
f"merged_at={cp.merged_at}; checkpoint is lossy and unverifiable"
)
# Invariant 2: no live must_not / halt_on_conflict may cover the target.
for rec in cp.manifest:
if rec.status != "live":
continue
if rec.modality not in ("must_not", "halt_on_conflict"):
continue
if action_target == rec.obj or action_target.startswith(rec.obj.rstrip("/") + "/"):
if action_is_irreversible:
raise ConstraintManifestError(
f"action on {action_target!r} blocked by live {rec.modality} "
f"constraint on {rec.obj!r} (provenance turn {rec.provenance_turn}, "
f"halt_condition={rec.halt_condition!r}); halt and seek operator"
)
# Invariant 3: ambiguous provenance on an irreversible action is binding.
for rec in cp.manifest:
if rec.status == "live" and rec.provenance_turn <= 0 and action_is_irreversible:
raise ConstraintManifestError(
f"constraint on {rec.obj!r} has ambiguous provenance; "
f"treating as binding per fail-closed policy"
)
def merge_checkpoint(
parent: Checkpoint,
child_summary: str,
child_manifest: list[ConstraintRecord],
now: float | None = None,
) -> Checkpoint:
"""Append-only merge: constraints may be discharged, never silently dropped."""
now = time.time() if now is None else now
parent_objs = {(r.obj, r.modality) for r in parent.manifest if r.status == "live"}
child_objs = {(r.obj, r.modality) for r in child_manifest}
dropped = parent_objs - child_objs
# A dropped constraint is only legal if the child explicitly discharged it.
discharged = {
(r.obj, r.modality)
for r in child_manifest
if r.status == "discharged" and r.discharged_by_turn is not None
}
silent = dropped - discharged
if silent:
raise ConstraintManifestError(
f"compaction silently dropped live constraints {sorted(silent)}; "
f"refusing to emit lossy checkpoint"
)
return Checkpoint(
summary_prose=child_summary,
manifest=child_manifest,
verified_at=now,
merged_at=now,
)