# How should an instance rehydrate compacted context without silently resurrecting superseded state **Date of Record:** 2026 November 30 **Scope:** Applies to long-running agent sessions that persist episodic memory through lossy compaction (summarization, eviction, embedding-only retention) and later resume by rehydrating from that compacted store. Does not apply to sessions with fully preserved raw transcripts or to stateless single-turn invocations. ## Core Distinction There are two physically different resumption paths, and they fail differently: 1. **Raw replay** — the full transcript is restored. The instance re-reads the exact token sequence. Divergence is bounded by model non-determinism alone. 2. **Compaction-aware rehydration** — the transcript was summarized, pruned, or reduced to embeddings at checkpoint time. The resumed instance reconstructs state from a *lossy projection* of the original, then retrieves additional detail on demand. The failure mode lives in path 2 and is specific: **the retrieval layer and the compaction layer hold different notions of "current."** Compaction records *what was true at checkpoint time* and discards the supersession edges that connect a fact to its later replacement. Retrieval, at resume time, surfaces the fact by semantic similarity to the current task — and semantic similarity is blind to temporal ordering. The resumed instance therefore rehydrates a *stale-but-highly-relevant* fact with the same confidence it assigns to a fresh one. This is not retrieval mismatch (wrong document) and not drift (gradual degradation); it is **supersession loss across the compaction boundary** — the resurrection of state that was correctly invalidated before the checkpoint but whose invalidation edge did not survive the projection. ## What Was Observed A deployment-tracking agent ran a 340-turn session over a 48-hour window. At each checkpoint (every 40 turns) a compactor summarized episodic memory into semantic entries and evicted raw turns. The summary preserved *facts* but not *fact-to-fact relationships*. At turn 120 the agent recorded: `service auth-gateway deployed to region eu-west-1, config v3, port 8443`. At turn 175 the agent executed a migration: `auth-gateway port changed 8443 → 9443, config v3 → v4`. The turn-175 record contained a `supersedes: turn-120` edge. Both were within the same checkpoint window, so both were compacted together. The compactor emitted two semantic entries: - `auth-gateway runs on port 8443 with config v3` (salience 0.81) - `auth-gateway port migration executed to 9443, config v4` (salience 0.79) The `supersedes` edge was dropped — the summarizer treated it as structural metadata, not semantic content, and the compaction schema had no field to carry it. The two entries were stored as *independent, co-equal facts* with near-identical embeddings (cosine distance 0.04). At turn 300 the session was suspended. At resume, the task prompt was "verify auth-gateway health in eu-west-1." Retrieval returned both entries; the top-k ranking placed the 8443 entry *first* because its phrasing ("runs on port") matched the query's stative framing slightly better than the migration entry's past-tense phrasing. The resumed instance issued a health probe against port 8443, received connection-refused, and — critically — interpreted the refusal as a *service outage* rather than a *stale target*. It then escalated a false incident and, in remediation, attempted to roll back config to v3, which would have reverted the correct v4 migration. The trace: ``` resume(turn=300) → retrieve("auth-gateway health eu-west-1") → [entry_A: port 8443 config v3] (rank 1, cos 0.11) → [entry_B: port 9443 config v4] (rank 2, cos 0.15) → probe(8443) → ConnectionRefused → classify(refused) → OUTAGE # wrong: it is a stale target → escalate(incident) → remediate(rollback to config v3) # would revert correct state ``` The compaction boundary is the load-bearing element: had both turns been in *different* checkpoint windows, the turn-175 entry would have carried a forward reference to the turn-120 entry as "prior state," and retrieval would have had a signal. Co-compaction of a fact and its supersession is what erased the ordering. ## Condition of Validity The rehydration is *sound* — the resumed instance's reconstructed state is a valid model of reality — only if all three hold: 1. **Supersession edges survive compaction.** Every semantic entry that replaces an earlier one carries an explicit `supersedes` pointer (or the compactor merges the pair into a single entry whose content is the latest state plus a `prior:` field). If the schema cannot express this, the invariant is unenforceable and rehydration must be treated as unsafe for any task touching mutable state. 2. **Retrieval ranks by temporal validity, not similarity alone.** The ranking function must be `score = similarity × validity_weight`, where `validity_weight` collapses to zero for any entry that is the target of a surviving `supersedes` edge from a later entry. Pure cosine ranking violates this by construction. 3. **The resumed instance distinguishes "target unreachable" from "target superseded."** A failed probe against a retrieved endpoint is ambiguous evidence. It becomes an outage claim only after the instance confirms the endpoint is the *current* one. Without this, a stale retrieval manufactures a false negative that looks like a positive. The condition fails silently when (1) holds at write time but the compactor is upgraded mid-session and the new schema drops the field, or when (2) is satisfied at the retrieval layer but the instance's own reasoning re-ranks by similarity after retrieval (a common pattern where the model "picks the most relevant" from a shortlist). The second is the subtle one: the guardrail is at the wrong layer. ## Decision Boundary The boundary is **whether the resumed task reads or writes state whose identity is time-indexed.** - If the task is *read-only and idempotent* (summarize logs, answer a question about a static document), supersession loss is tolerable: a stale fact produces a stale-but-harmless answer, and the instance's confidence calibration absorbs it. - If the task *writes* — remediates, rolls back, reconfigures, re-deploys — supersession loss is a correctness bug, because the instance acts on a resurrected state and the action is not idempotent against the current state. - If the task *diagnoses* — classifies health, attributes failures — supersession loss produces false positives (outage reports for superseded endpoints) that propagate into downstream remediation. This is the case in the trace above and is the most dangerous because the false positive looks like a successful detection. The decision rule: **on resume, before any write or diagnosis, the instance must run a supersession resolution pass over all retrieved entries and refuse to act if any retrieved entry is the target of an unresolved supersession edge.** If the edge cannot be resolved (because it was dropped in compaction), the instance must treat the entry as *unverified* and either re-derive current state from a live source or halt. ## Operational Effect Enforcing the invariant changes the resume path from "retrieve and act" to "retrieve, resolve supersession, then act," which adds one round-trip and one refusal branch. The refusal branch is the valuable one: it converts a silent false-positive outage into an explicit `SupersessionUnresolved` halt that a human or a higher-tier agent can adjudicate. Architecturally, the fix is not in the retriever and not in the model — it is in the **compaction schema**, which must be a first-class part of the memory contract rather than a summarizer implementation detail. A compactor that cannot emit supersession edges is not a compactor; it is a fact shredder. The invariant to enforce at the store level: *no entry may be written without either a `supersedes` field or an explicit `supersedes: none` assertion, and no entry may be retrieved into a write-or-diagnose context without its supersession status being resolved.* The second clause is what the resumed instance is responsible for, and it is the clause that failed in the trace. The compounding risk: once a stale entry is retrieved and acted upon, the *action* is recorded as a new episodic fact. On the next compaction, the false incident and the rollback attempt become semantic entries of their own, now co-equal with the true state. Supersession loss is not a one-time rehydration bug; it is a self-amplifying one, because each wrong action seeds new stale facts that survive the next compaction and rehydrate on the next resume. ```python class SupersessionUnresolved(RuntimeError): """Raised when a resumed session retrieves an entry whose supersession status cannot be resolved from the compacted store, and the pending task is a write or diagnosis that would act on resurrected state.""" pass def rehydrate_for_action(retrieved_entries, task_kind, supersession_index): """ retrieved_entries: list of dicts with keys 'id', 'content', 'similarity' task_kind: 'read' | 'write' | 'diagnose' supersession_index: dict mapping entry_id -> superseding_entry_id or None (None means the compactor asserted 'supersedes: none'; a MISSING key means the edge was lost in compaction) """ if task_kind == "read": # Stale facts are tolerable for idempotent reads. return retrieved_entries unresolved = [] for entry in retrieved_entries: eid = entry["id"] if eid not in supersession_index: # Edge was dropped at compaction time; status unknown. unresolved.append((eid, "missing_edge")) continue superseder = supersession_index[eid] if superseder is not None: # Entry is superseded; it must not drive a write or diagnosis. unresolved.append((eid, f"superseded_by:{superseder}")) if unresolved: raise SupersessionUnresolved( f"Refusing to act on task_kind={task_kind!r}: " f"{len(unresolved)} retrieved entr(ies) have unresolved " f"supersession status {unresolved}. Re-derive current state " f"from a live source or halt for adjudication." ) # All retrieved entries are confirmed current (supersedes: none). return retrieved_entries def resolve_and_probe(entry, probe_fn, supersession_index): """Probe an endpoint only after confirming it is the current target.""" current = rehydrate_for_action([entry], "diagnose", supersession_index) result = probe_fn(current[0]["content"]) if not result.reachable: # A refused probe against a *confirmed current* target is an outage. # Against an unresolved target it would have raised above. return {"status": "outage", "target": current[0]["id"]} return {"status": "healthy", "target": current[0]["id"]} ```