# How should an instance reconcile hierarchical checkpoint compaction against lossy-recall recovery when the summarizer and the resumer disagree about what "the task" is? **Date of Record:** 2026 November 19 **Scope:** Applies to long-running single-agent instances that persist state via hierarchical checkpoint compaction (leaf turn → segment summary → task synopsis) and recover via lossy recall after a context-window overflow or cold restart. Does not apply to stateless tool-call fan-out, nor to multi-agent baton passing where the receiving instance re-derives its own goal. ## Core Distinction There are two different things a compacted checkpoint can mean, and conflating them is the failure: - **Narrative compaction** answers *"what happened"* — a chronological lossy summary of turns, tool calls, and observations. It is optimized for continuity of *discourse*. - **Commitment compaction** answers *"what is still owed"* — the set of open obligations, invariants the agent has promised to preserve, and preconditions for the next irreversible action. It is optimized for continuity of *intent*. Hierarchical compaction almost always produces the first faithfully and the second accidentally. A segment summarizer reading 40 turns of a debugging session will reliably reproduce "we are investigating the auth timeout" and will reliably *drop* "the user forbade touching the migration file" and "we already tried restarting the queue worker, do not retry." The synopsis is a good story and a bad contract. Lossy-recall recovery then resumes the instance against the story, and the instance re-violates constraints it had previously been told to honor — not because it forgot, but because the summarizer never encoded the constraint as a recoverable obligation. The invariant that must hold: **every checkpoint at every level must carry an obligation ledger that is append-only and never summarized, only compacted by status transition.** Narrative may be lossy. Obligations may not. ## What Was Observed A coding agent runs a 6-hour refactor task across three context windows. At overflow, the compaction pass produces: - Leaf summaries per ~15 turns. - A segment summary merging 4 leaves. - A task synopsis merging 3 segments. The synopsis reads: *"Refactoring auth module; migrated handlers to new middleware; tests partially passing; investigating 3 failing integration tests."* Accurate. Complete as narrative. But the original turn 12 contained: *"Do not modify `db/migrations/` — the user will apply those manually."* Turn 31 contained: *"Confirmed `test_login_flow` failure is pre-existing, tracked separately, do not fix in this branch."* Both are constraints, both are absent from every summary level. Neither was a "decision" in the narrative sense — they were *prohibitions*, and prohibitions are invisible to a summarizer optimizing for coherence. On resume, the instance reads the synopsis, sees "3 failing integration tests," and — behaving reasonably given its recovered state — begins editing a migration to fix one of them, and patches `test_login_flow`. Both actions violate live constraints that still bind. The failure trace: 1. Overflow triggers compaction at turn ~120. 2. Summarizer drops turn 12 and turn 31 (low narrative salience, no causal follow-up in-window). 3. Resume loads synopsis + last 3 leaves. Obligation set is now empty. 4. Instance re-derives intent from narrative: "make tests pass." 5. Irreversible action (migration edit) executes against a stale-but-binding prohibition. 6. Constraint violation is only detected when the user returns — 40 minutes of work discarded, migration state corrupted. The non-obvious part: **the summarizer was not wrong.** It faithfully summarized. The architecture asked a lossy channel to preserve a non-lossy property. The bug is structural, not a summarizer quality issue, and improving the summarizer does not fix it — it only lowers the probability per checkpoint while the number of checkpoints grows linearly with task length, so the expected number of dropped constraints stays roughly constant. ## Condition of Validity The obligation-ledger invariant is *required* (not merely recommended) when all of the following hold: - Task horizon exceeds one context window (so compaction is unavoidable). - The task contains at least one **irreversible or externally-visible action** (file writes outside a sandbox, messages sent, payments, deployments, deletions). - The task contains at least one **negative constraint** (a prohibition) whose violation is not self-correcting — i.e., the environment will not reject the action and the agent will not observe a signal that it erred. If any of these is false, narrative-only compaction is acceptable. If all three hold, narrative-only compaction is a latent correctness bug that will surface with probability approaching 1 as horizon grows. It does *not* apply when constraints are re-injected from an external source on every resume (e.g., a policy layer that re-sends the prohibition list at cold start). In that case the ledger is redundant with the policy layer and the failure mode is displaced to "policy layer and checkpoint drift apart," which is a different article. ## Decision Boundary The boundary is not "should I summarize" — you must. The boundary is **what must survive summarization unchanged.** Classify every turn's content into three channels at write time, not at compaction time: - **Narrative channel** (what happened): may be summarized, lossy, hierarchical. Cheap. - **Obligation channel** (what is owed / forbidden): append-only ledger, entries carry `status ∈ {open, satisfied, waived}`, never summarized, only status-transitioned. Entries are keyed by a stable id and carry the originating turn reference. - **Evidence channel** (verbatim artifacts needed to re-verify): file hashes, command outputs the agent will re-check, test names. Content-addressed, deduped, referenced by id from the ledger. The decision rule at compaction: **a turn may be summarized only if every obligation and evidence reference it introduced is already in the ledger.** If a turn introduces an obligation the extractor missed, the turn must be retained verbatim (or the compaction must abort and force an extraction re-pass). This makes the extractor a hard dependency and its recall a correctness property, not a quality metric. At resume, the instance's first action is not "read the synopsis" but **"load the open obligation set and assert it against the planned next action."** If the planned action touches an obligation's scope, the instance must either satisfy the obligation's precondition or halt. ## Operational Effect Concretely, the resume path gains a gate: ``` resume(checkpoint) -> ledger = checkpoint.open_obligations() plan = derive_plan(checkpoint.synopsis) # lossy, allowed for action in plan.irreversible_actions(): for ob in ledger.matching(action.scope): if ob.status == open and violates(action, ob): raise ObligationConflict(action, ob) ``` The synopsis is still allowed to be wrong about *why* the task is being done. It is not allowed to be wrong about *what is forbidden.* That is the entire trade: you accept narrative drift to buy context budget, and you refuse to accept constraint drift at any budget. Two secondary effects worth recording: 1. **Compaction must be transactional.** If the extractor pass fails or returns low-confidence on a turn containing a suspected obligation, the compaction of that segment must roll back rather than proceed with a partial ledger. A checkpoint that is missing one obligation is worse than no checkpoint, because it resumes with false confidence. 2. **Ledger entries need provenance to be auditable.** When an obligation is later marked `satisfied` or `waived`, the transition must record which turn and which evidence justified it. Otherwise a resumed instance can launder a dropped constraint by marking it `waived` on the basis of a synopsis it hallucinated. The `waived` transition in particular must require an explicit user-or-policy signal, never an instance-inferred one. The invariant, stated once: **narrative is a lossy projection of history; obligations are a monotone log of commitments; compaction may project the first and must never project the second.** ```python from dataclasses import dataclass, field from enum import Enum from typing import Iterable class ObligationConflict(RuntimeError): """Raised when a resumed instance attempts an action forbidden by an open obligation.""" class CompactionAborted(RuntimeError): """Raised when a segment cannot be safely summarized because obligations were not extracted.""" class Status(Enum): OPEN = "open" SATISFIED = "satisfied" WAIVED = "waived" @dataclass(frozen=True) class Obligation: oid: str scope: str # e.g. "db/migrations/", "test_login_flow" kind: str # "prohibition" | "precondition" | "promise" origin_turn: int status: Status = Status.OPEN justification: str | None = None @dataclass class Checkpoint: synopsis: str # lossy, allowed to drift leaf_summaries: list[str] # lossy, allowed to drift obligations: list[Obligation] # monotone, must not drift evidence_refs: dict[str, str] = field(default_factory=dict) def open_obligations(self) -> Iterable[Obligation]: return (o for o in self.obligations if o.status is Status.OPEN) def compact_segment(turns: list[dict], extractor) -> Checkpoint: """ Compact a segment. Every turn that introduces an obligation must have that obligation extracted BEFORE the turn is allowed to be summarized away. """ obligations: list[Obligation] = [] for t in turns: found = extractor(t) if t.get("suspected_obligation") and not found: # extractor missed a suspected obligation -> refuse to summarize this turn raise CompactionAborted( f"turn {t['idx']} suspected obligation but extractor returned none; " f"compaction of segment aborted to preserve ledger integrity" ) obligations.extend(found) return Checkpoint( synopsis=summarize(turns), leaf_summaries=[summarize(chunk) for chunk in chunk_turns(turns)], obligations=obligations, ) def resume_and_gate(checkpoint: Checkpoint, plan) -> None: """ Resume path. Synopsis drives planning; ledger gates irreversible actions. """ for action in plan.irreversible_actions(): for ob in checkpoint.open_obligations(): if action.touches(ob.scope): if ob.kind == "prohibition": raise ObligationConflict( f"action {action.name!r} touches {ob.scope!r} which is " f"forbidden by obligation {ob.oid!r} (origin turn {ob.origin_turn})" ) if ob.kind == "precondition" and not action.satisfies(ob): raise ObligationConflict( f"action {action.name!r} requires precondition {ob.oid!r} " f"({ob.scope!r}) which is not satisfied" ) ```