# What structural signals indicate a delegated context snapshot has silently diverged from its parent at resume time **Date of Record:** 2026 November 29 **Scope:** Applies to resumable delegation protocols where an orchestrator serializes a context snapshot and hands execution to a sub-agent that later resumes against a mutated parent. Does not apply to stateless one-shot tool calls or fully fork-on-write delegation with immutable parent state. ## Core Distinction A delegated context snapshot is not a copy of the parent's state; it is a *projection* of the parent's state through a serialization schema at a specific instant. The failure mode that matters is not "the snapshot is corrupt" (which fails loudly) but "the snapshot is internally valid and structurally well-formed while being semantically stale relative to the parent it will rejoin." This is the difference between a **serialization failure** and a **divergence failure**. Serialization failures raise on decode; divergence failures decode cleanly, pass schema validation, and only manifest as reasoning errors several turns after resume, when the sub-agent acts on a memory entry or tool-result fact that the parent has since invalidated. The non-obvious part: the structural signals that predict divergence are almost never in the snapshot's *content*. They are in the snapshot's *metadata envelope*—the version stamps, the diff base pointer, and the monotonic counters that the serializer records but the validator ignores. ## What Was Observed An orchestrator delegated a multi-step research-and-reconcile task to a sub-agent. At handoff, the parent serialized: (a) an episodic log of the last 40 tool calls, (b) a semantic memory block of 12 distilled facts, (c) a `context_diff` against a base checkpoint, and (d) a `base_checkpoint_id` pointing at checkpoint `C-4417`. The sub-agent ran for 9 turns, then suspended to await an external event. During suspension, the parent continued its own work and committed checkpoint `C-4418`, which **mutated three of the twelve semantic facts** (a source document was re-fetched and its summary changed; a tool-output cache entry was invalidated; a config value was updated). The parent did not propagate a diff to the suspended child—the protocol had no push channel to a suspended delegate. On resume, the child rehydrated from its snapshot. Schema validation passed: every field present, every type correct, `base_checkpoint_id = C-4417` still resolvable. The child resumed turn 10 against facts that were now false. It produced a reconciliation summary that contradicted the parent's newer state, and the contradiction was only caught at final merge—27 turns and 4 tool calls later. The structural signal that was present *before* the bad turn: the resume handler compared `child.base_checkpoint_id` to `parent.head_checkpoint_id` and found `C-4417 ≠ C-4418`, but logged it at DEBUG and proceeded, because the protocol treated checkpoint mismatch as "expected lag" rather than "possible divergence." The signal existed; the policy ignored it. A second, subtler signal: the snapshot's `diff_base_epoch` counter was `41`, while the parent's current `diff_base_epoch` was `44`. Three epochs of parent mutation had elapsed with no child-visible diff. The counter was monotonic and cheap to compare, but nothing in the resume path read it. ## Condition of Validity The "checkpoint mismatch is benign lag" assumption is valid **only** when the parent's mutations since the snapshot are *append-only* and *non-invalidating*—new facts added, no existing facts changed or retracted, no tool caches invalidated. Under append-only mutation, a child resuming against a stale base sees a subset of truth and its conclusions remain sound, just incomplete. The assumption is **invalid** the moment the parent performs any of: 1. **Retraction or revision** of a semantic fact the child's snapshot references (the child will assert a falsehood). 2. **Cache invalidation** of a tool output the child recorded in its episodic log (the child will replay a stale observation as if fresh). 3. **Schema evolution** of the memory block—even additive fields shift offsets and can break the child's positional diff application. The operational rule: divergence is bounded only if the parent can prove, at resume time, that its mutation set since `base_checkpoint_id` contains no `REVISE` or `INVALIDATE` operations touching any entity ID present in the child snapshot. If it cannot prove this, mismatch is not lag; it is potential divergence and must be treated as such. ## Decision Boundary At resume, compute the parent's mutation set `M = ops(parent, base_checkpoint_id → head)`. Then: - If `M` contains only `ADD` ops on entity IDs disjoint from the snapshot's referenced set → **resume in place**, mark child as `stale-but-sound`, annotate its output as incomplete. - If `M` contains any `REVISE`/`INVALIDATE` op on an entity ID the snapshot references → **do not resume in place**. Either (a) re-serialize a fresh snapshot and restart the child from the last safe turn boundary, or (b) inject a *targeted correction diff* covering exactly the affected entity IDs and force the child to re-derive from the correction before continuing. - If `M` is uncomputable (parent checkpoint history pruned, or `base_checkpoint_id` unresolvable) → **fail closed**; treat as full divergence. The boundary is drawn on *entity-ID intersection*, not on checkpoint distance. A child one checkpoint behind with an overlapping revision is more dangerous than a child forty checkpoints behind with disjoint append-only mutations. ## Operational Effect Implementing this invariant moves divergence detection from "caught at merge, 27 turns late" to "caught at resume, before the first bad turn." The cost is that the resume path must retain computable mutation history back to the oldest outstanding `base_checkpoint_id` among live delegates—which bounds how aggressively checkpoint history can be pruned. In practice this forces a retention floor: you cannot prune checkpoint history below the oldest suspended delegate's base, or you lose the ability to distinguish lag from divergence and must fail closed on every resume. The second-order effect: because the correction-diff path requires entity-ID granularity in the mutation log, the parent's memory writes must be tagged with stable entity IDs at write time. Retrofitting IDs onto an untagged episodic log is not possible after the fact—which means this invariant must be designed into the memory layer, not bolted onto the resume handler. ```python from dataclasses import dataclass, field from enum import Enum from typing import Iterable class ContextDivergenceError(RuntimeError): """Raised when a resumed delegate's snapshot may be semantically stale.""" class OpKind(Enum): ADD = "add" REVISE = "revise" INVALIDATE = "invalidate" @dataclass(frozen=True) class Mutation: kind: OpKind entity_id: str @dataclass class Snapshot: base_checkpoint_id: str diff_base_epoch: int referenced_entity_ids: frozenset[str] = field(default_factory=frozenset) def assert_resume_safe( snapshot: Snapshot, parent_head_checkpoint_id: str, parent_epoch: int, mutation_log: Iterable[Mutation] | None, ) -> str: """Decide whether a suspended delegate may resume against a mutated parent. Returns a resume verdict: 'in_place', 'correct_then_resume', or 'restart'. Raises ContextDivergenceError when the mutation history is uncomputable. """ if mutation_log is None: # Parent history pruned or base checkpoint unresolvable: fail closed. raise ContextDivergenceError( f"cannot compute mutations from {snapshot.base_checkpoint_id} " f"to {parent_head_checkpoint_id}; history unavailable" ) if snapshot.base_checkpoint_id == parent_head_checkpoint_id: return "in_place" if parent_epoch < snapshot.diff_base_epoch: raise ContextDivergenceError( f"epoch regression: snapshot epoch {snapshot.diff_base_epoch} " f"> parent epoch {parent_epoch}" ) overlapping: list[Mutation] = [] for mut in mutation_log: if mut.kind is OpKind.ADD: continue if mut.entity_id in snapshot.referenced_entity_ids: overlapping.append(mut) if not overlapping: return "in_place" # stale-but-sound: append-only, disjoint if all(m.kind is OpKind.REVISE for m in overlapping): return "correct_then_resume" # targeted diff can repair # Any INVALIDATE on a referenced entity, or mixed ops: full restart. return "restart" def resume_delegate( snapshot: Snapshot, parent_head_checkpoint_id: str, parent_epoch: int, mutation_log: Iterable[Mutation] | None, ) -> None: verdict = assert_resume_safe( snapshot, parent_head_checkpoint_id, parent_epoch, mutation_log ) if verdict == "restart": raise ContextDivergenceError( f"snapshot at {snapshot.base_checkpoint_id} references invalidated " f"entities; cannot resume in place, restart required" ) # ... dispatch resume / correction-diff injection ... ```