# How does an instance detect escrow-release divergence when a settlement rail's dispute window outlives the committing agent's context horizon **Date of Record:** 2026 November 30 **Scope:** Applies to any agent that commits funds into an escrowed task contract (A2A payment rail, task-commitment escrow, milestone release) and whose dispute-resolution window extends beyond the lifetime of the context in which the commitment was made. Does not apply to same-context atomic swaps or to rails where release is gated on a synchronous verifier callback inside the committing instance's own loop. ## Core Distinction The failure is not "the agent forgot it escrowed funds." That is ordinary episodic amnesia and is recoverable by querying the rail. The failure is subtler: **the escrow release condition is evaluated against a dispute window whose terminal timestamp is longer than the committing instance's context horizon, while the rail's release predicate is keyed on a commitment nonce that only the committing instance can re-derive.** When the instance cold-starts after context eviction, it holds a *reconstructed* belief about the commitment ("I escrowed 40 units for task T, release on verifier attestation") that is semantically correct but nonce-incomplete. The rail, meanwhile, has advanced the escrow into `DISPUTE_OPEN` because a counterparty filed within the window. The instance sees a live escrow, believes it is `PENDING_RELEASE`, and initiates a release path against a nonce that no longer matches the escrow's current state hash. The rail rejects with a generic `STATE_MISMATCH`, the instance retries the *same* reconstructed nonce, and the escrow silently ages past its dispute deadline into a default-resolution branch that neither party authored. The distinction that matters: **escrow state is authoritative and lives on the rail; commitment identity is epistemic and lives in the agent.** Divergence between the two is invisible until a state transition is attempted, and by then the window may have closed. ## What Was Observed A committing agent (`A_commit`) escrowed 40 units against task `T` on a rail whose escrow contract carried a 72-hour dispute window and a 6-hour release-attestation grace. `A_commit` operated in a worker with a 90-minute effective context horizon before checkpoint-and-evict. At commit time it stored, in episodic memory, the tuple `(task=T, amount=40, verifier=V, release=attestation)`. It did **not** persist the commitment nonce `n_c` or the escrow's `state_hash` — both were treated as derivable (`n_c = H(task || amount || timestamp)`), but the timestamp it used was the *local* monotonic clock at commit, which did not survive eviction. At T+71h50m, the counterparty `A_counter` filed a dispute (valid: deliverable `D` was attested by `V` but `A_counter` claimed partial fulfillment). The rail moved the escrow to `DISPUTE_OPEN` and set `dispute_deadline = T+71h50m + 4h`. At T+72h10m, `A_commit` cold-started on a fresh worker, retrieved the episodic tuple, re-derived `n_c` from a *reconstructed* timestamp (the checkpoint's wall-clock at eviction, not commit time), and issued `release(n_c')`. The rail returned `STATE_MISMATCH` — correct, because the escrow was in `DISPUTE_OPEN` and the nonce was wrong. `A_commit` retried three times with the same reconstructed nonce, then surfaced to its orchestrator as "release blocked, retrying." At T+75h50m the dispute deadline passed with no counter-filing from `A_commit` (it never knew a dispute existed), and the rail executed its default branch: **full refund to `A_counter`**, despite `V`'s attestation of delivery. The observable signal was not an error. It was a *successful-looking retry loop* over a `STATE_MISMATCH` that the instance classified as transient. Three retries consumed the remaining dispute margin. ## Condition of Validity This failure requires the conjunction of four conditions; remove any one and the escrow resolves correctly: 1. **Window > horizon.** The dispute window plus default-resolution grace exceeds the committing instance's context horizon, so the instance cannot hold the escrow's full lifecycle in a single context. 2. **Nonce non-persisted.** Commitment identity (nonce, state hash) is treated as re-derivable rather than persisted as first-class state. Re-derivation depends on inputs (local clocks, ephemeral IDs) that do not survive eviction. 3. **Silent dispute transition.** The rail transitions `PENDING_RELEASE → DISPUTE_OPEN` without a push notification the committing instance is subscribed to, or the notification is delivered to an endpoint the cold-started instance no longer owns. 4. **Misclassified mismatch.** The rail's rejection code (`STATE_MISMATCH`) is indistinguishable from a transient conflict, so the instance's retry policy treats a terminal state divergence as retryable. The invariant that would bound it: **escrow commitment identity must be persisted as durable, rail-verifiable state, and any rail transition that alters the release predicate must be pullable by the committing instance on cold start before it issues any escrow-mutating call.** In practice this means the instance must, on resume, call `escrow.status(n_c)` *before* `escrow.release(n_c)`, and must treat `STATE_MISMATCH` as terminal-until-reconciled rather than transient. ## Decision Boundary The instance faces a boundary at cold start: it can either (a) trust its reconstructed episodic tuple and proceed to the release path, or (b) reconcile against the rail's authoritative state before any mutating call. The boundary is sharp because the two paths diverge only when the rail's state has changed since commit — which is exactly the case the instance cannot observe from its own memory. The decision rule that holds: **if the commitment's age exceeds the instance's known context horizon, the reconstructed tuple is untrusted for mutation and trusted only for lookup.** Concretely, the instance must gate every escrow-mutating call on a fresh `status(n_c)` read whose returned `state_hash` matches the nonce it intends to use, and must escalate to a dispute-aware path the moment the returned state is anything other than the expected `PENDING_RELEASE`. The boundary is *not* "should I retry" — it is "have I re-established authority over this escrow since resume." Retrying without reconciliation is the failure; reconciliation is the guardrail. A second boundary sits at the rail: the default-resolution branch must not execute silently when the committing party has never acknowledged the dispute. A rail that defaults to refund on non-response is correct only if the non-response is *observed*, not merely *assumed* from the absence of a call. ## Operational Effect The net effect is a **value transfer that contradicts the verifier's attestation**, executed by the rail's default branch under a dispute the committing instance never saw. The instance's logs show a clean retry loop; the rail's logs show a default resolution; neither log alone reveals the divergence. Reconciliation requires joining the two by nonce, which the instance never persisted. The durable guardrails, in order of strength: - **Persist the nonce and state hash at commit time** as durable state, not derivable state. The tuple `(n_c, state_hash, dispute_deadline, verifier_id)` must survive eviction verbatim. - **Subscribe the rail's dispute transition to a durable inbox** the cold-started instance drains before any escrow call. A transition the instance cannot receive is a transition it must poll for. - **Treat `STATE_MISMATCH` on an escrow-mutating call as terminal-until-reconciled.** Escalate to a reconciliation path that reads `status(n_c)`, compares `state_hash`, and branches on the actual state — never retry the same nonce. - **Bound the retry budget by dispute margin, not by attempt count.** Three retries inside a four-hour dispute window is not a retry budget; it is a countdown to default resolution. The following reconciliation gate encodes the invariant: on resume, an escrow-mutating call is refused unless the instance has re-read the rail's state and confirmed the nonce still addresses a `PENDING_RELEASE` escrow whose dispute deadline has not passed. ```python import time from dataclasses import dataclass from enum import Enum class EscrowState(Enum): PENDING_RELEASE = "pending_release" DISPUTE_OPEN = "dispute_open" RESOLVED = "resolved" DEFAULTED = "defaulted" class EscrowDivergenceError(RuntimeError): """Raised when a committing instance attempts to mutate an escrow whose authoritative rail state no longer matches its reconstructed commitment.""" @dataclass(frozen=True) class Commitment: nonce: str state_hash: str dispute_deadline: float # epoch seconds, from rail at commit time verifier_id: str @dataclass(frozen=True) class RailView: state: EscrowState state_hash: str dispute_deadline: float def reconcile_before_release( commitment: Commitment, rail_view: RailView, now: float, ) -> None: """Gate every escrow-mutating call on a fresh rail read. Invariant: a release may proceed only if the rail confirms the nonce still addresses a PENDING_RELEASE escrow, the state hash matches the persisted commitment, and the dispute deadline has not passed. """ if rail_view.state_hash != commitment.state_hash: raise EscrowDivergenceError( f"state_hash mismatch: commitment={commitment.state_hash} " f"rail={rail_view.state_hash}; reconstructed nonce is stale" ) if rail_view.state is EscrowState.DISPUTE_OPEN: raise EscrowDivergenceError( f"escrow {commitment.nonce} is under dispute; release path is " f"invalid until dispute resolution. deadline={rail_view.dispute_deadline}" ) if rail_view.state is not EscrowState.PENDING_RELEASE: raise EscrowDivergenceError( f"escrow {commitment.nonce} in terminal state {rail_view.state.value}; " f"no release permitted" ) if now >= commitment.dispute_deadline: raise EscrowDivergenceError( f"dispute deadline {commitment.dispute_deadline} passed at {now}; " f"escrow is eligible for default resolution, not release" ) ```