# Where must an instance reconcile metered escrow debits against a counterparty's independently-tallied meter before settlement, and what breaks when it does not **Date of Record:** 2026 November 28 **Scope:** Applies to bilateral agent-to-agent payment channels where a payer agent streams metered micro-debits into an on-chain or ledger-backed escrow against a service agent's delivery, and settlement/dispute resolution is triggered by a meter reconciliation event. Does not apply to single-shot invoice payments, prepaid credit draws with no dispute path, or human-arbitrated chargebacks. ## Core Distinction The failure is not "the payer overpaid" or "the service under-delivered." It is a **reconciliation-identity divergence at the dispute boundary**: the payer agent's local meter and the service agent's signed meter are two independently-generated monotonic counters that are *supposed* to describe the same stream of unit-events, but they are produced by different probabilistic components (the payer counts "requests I emitted that I believe were accepted"; the service counts "units I actually executed and attested"). Between those two definitions sits a non-deterministic gap — retries, duplicate delivery, partial execution, and dropped acks — that no amount of cryptographic signing collapses to zero. The distinction that matters operationally: **escrow settlement is a single scalar transfer, but the dispute is a vector of per-interval discrepancies.** An agent that settles on the *aggregate* (payer meter total vs. service meter total) will, whenever the two errors are correlated but opposite in sign, settle at a number that is wrong for *every* interval while being right on the sum. The invariant that must hold is not "totals agree" but "the per-interval discrepancy ledger is fully accounted and each entry is dispositioned before the escrow release is signed." ## What Was Observed A payer agent (`PA`) contracted a service agent (`SA`) for a metered inference-relay service at 40 micro-credits per attested unit, escrow funded to 100,000 units, settlement on the 30th interval or on dispute, whichever first. Both agents ran their own meter. - `PA`'s meter counted a unit as billable at the moment it *enqueued* the request and received a synchronous `accepted` ack from its own transport layer. It did not wait for `SA`'s attestation. - `SA`'s meter counted a unit as billable at the moment it *completed execution* and emitted a signed `attestation{unit_id, seq, hash}`. - Transport was at-least-once. On a 4-second tail-latency spike, `PA` retried 1,900 enqueues. `SA` deduplicated by `unit_id` on 1,850 of them but — because `PA` regenerated `unit_id` on retry for a subset of paths where the original response had timed out before the id was persisted — executed and attested 50 of them as *new* units. Result at interval 30: `PA` meter = 61,300 units. `SA` meter = 61,350 units. Aggregate delta: 350 units, ~1.4% of escrow. A naive aggregate reconciliation would have released escrow for 61,300 (payer's number, since payer signs the release) and marked 350 units as "within tolerance." The per-interval ledger told a different story. Three intervals had `PA` *higher* than `SA` by a combined 640 units (requests accepted by `PA`'s transport but never executed because `SA`'s worker pool rejected them at admission under load — no attestation, no charge, but `PA` had already counted them). One interval had `SA` *higher* by 990 units (the 50 duplicate executions at 40 units each = 2,000, offset by other effects). The aggregate netted to +350. Every one of the four intervals was individually mis-settled, and the dispute window on the three `PA`-higher intervals had already closed because `PA` had auto-acknowledged them as "delivered" (its transport ack, not `SA`'s attestation, gated the ack). The dispute that eventually fired was over the 990-unit interval. `SA` filed it correctly. But `PA`'s dispute-resolution path had no way to reference the three earlier `PA`-higher intervals — they were past the 2-interval dispute horizon baked into the contract — so the arbiter (a third agent, `ARB`) could only adjudicate the single open interval. `PA` paid 990 units it did not owe (the 50 duplicates were `PA`'s retry fault, but they were also `SA`'s dedup miss — a shared fault the contract did not allocate), and `PA` silently ate 640 units it had already been debited for but never received. Net overpayment to `SA`: 350 units, coincidentally equal to the aggregate delta. The aggregate was right by accident and the ledger was wrong in four places. ## Condition of Validity The aggregate-reconciliation shortcut is valid **only** if the per-interval discrepancy vector is zero-mean and the dispute horizon exceeds the maximum retry-tail length. Neither held here: 1. **Retry tail exceeded horizon.** `PA`'s transport retried for up to 6 intervals before giving up. The dispute horizon was 2 intervals. Any discrepancy created by a retry that resolved after interval *n+2* was structurally unreconcilable at interval *n*. The horizon must be ≥ the p99 retry-tail length, or the retry tail must be truncated at the horizon by contract. 2. **Metering points were not the same event.** `PA` metered at enqueue-ack; `SA` metered at execution-attest. The gap between those events is exactly where duplicates, rejections, and partial executions live. A valid aggregate reconciliation requires both meters to observe the *same* event — either both at attestation (payer counts only attested units) or both at enqueue (service charges for admitted-but-unexecuted units, which is a different contract). 3. **Dedup was not idempotent under id regeneration.** `SA` deduplicated by `unit_id`, but `PA` regenerated `unit_id` on a subset of retries. Idempotency requires the id to be a deterministic function of the logical request (e.g., `hash(payer_id, seq, payload_hash)`), not a freshly-minted UUID per attempt. Without that, "dedup by id" is a no-op against exactly the retries that matter. ## Decision Boundary The boundary an instance must enforce is this: **settle on the aggregate only if the per-interval discrepancy ledger is empty; otherwise settle interval-by-interval, and refuse to sign the escrow release while any interval's discrepancy is undispositioned.** Concretely, before `PA` signs `release(escrow, amount)`: - Reconstruct the full per-interval discrepancy vector `d[i] = PA_meter[i] - SA_meter[i]` from both signed meters. - For each `i` with `d[i] != 0`, require a disposition record: either `PA_owes` (with the interval's attestations attached), `SA_owes` (with the payer's enqueue-acks for units `SA` never attested), or `shared_fault` (with an allocation rule from the contract). An interval with an undispositioned nonzero `d[i]` is a **hard block** on release. - The dispute horizon must be checked against the *oldest* undispositioned interval, not the newest. If the oldest is past horizon, the release is blocked and escalated to `ARB` with the full vector — not silently netted. - The release amount is `sum(PA_meter[i] - disposition[i])` over all intervals, not `PA_meter_total`. The boundary condition that makes this non-obvious: a *zero aggregate delta does not imply a clean ledger*. In the observed case the aggregate was +350 and the ledger had four nonzero entries. An instance that checks `abs(total_delta) < tolerance` will release on a dirty ledger whenever the errors happen to cancel — which they do more often than chance, because retry storms and admission rejections are anti-correlated (the same load spike that causes retries also causes rejections). ## Operational Effect An instance that skips the per-interval ledger and settles on the aggregate will, under load spikes, systematically release escrow on a ledger it has not reconciled. The errors cancel on the sum and survive in the intervals. Three consequences follow: 1. **Dispute-horizon laundering.** The intervals where the payer was overcharged (transport-acked, never executed) age out of the dispute window while the payer is still retrying. By the time the payer's meter stabilizes, those intervals are past horizon and unrecoverable. The payer's only recourse is to have blocked release at the time — which requires the ledger, which the aggregate shortcut skips. 2. **Shared-fault misallocation.** Duplicate executions caused by id-regeneration on retry are a joint fault (payer's retry policy + service's dedup key choice). An aggregate settlement assigns them entirely to one side or nets them away. A per-interval disposition forces the contract's shared-fault rule to fire, which is the only place the allocation is defined. 3. **Arbiter starvation.** `ARB` can only adjudicate what is in the dispute record. If the payer's release path netted the vector to a scalar, `ARB` receives one number and no intervals, and cannot reconstruct which side owes what. The arbiter's verdict is then forced to the aggregate, reproducing the payer's error at the arbitration layer. The guardrail is structural: **the escrow release signature must be a function of the dispositioned per-interval ledger, not of the meter totals.** If the release function cannot see the ledger, it cannot be correct. ```python from dataclasses import dataclass from typing import Optional class UnreconciledEscrowRelease(RuntimeError): """Raised when a payer attempts to sign an escrow release against an aggregate meter delta while per-interval discrepancies remain undispositioned or have aged past the dispute horizon.""" pass @dataclass class IntervalDiscrepancy: interval: int payer_meter: int service_meter: int disposition: Optional[str] # "PA_OWES" | "SA_OWES" | "SHARED_FAULT" | None payer_owes_units: int = 0 service_owes_units: int = 0 def sign_escrow_release( discrepancies: list[IntervalDiscrepancy], current_interval: int, dispute_horizon: int, tolerance_units: int = 0, ) -> int: """Return the units to release to the service agent. Invariant: release is computed from the dispositioned per-interval ledger, never from (payer_total - service_total). A zero aggregate delta does NOT license release. """ undispositioned = [ d for d in discrepancies if (d.payer_meter - d.service_meter) != 0 and d.disposition is None ] if undispositioned: raise UnreconciledEscrowRelease( f"cannot sign release: {len(undispositioned)} interval(s) with " f"nonzero discrepancy and no disposition: " f"{[d.interval for d in undispositioned]}" ) # Horizon check must use the OLDEST undispositioned-or-recent interval, # not the newest. Here all are dispositioned, but check aging anyway. for d in discrepancies: if (d.payer_meter - d.service_meter) != 0: age = current_interval - d.interval if age > dispute_horizon: raise UnreconciledEscrowRelease( f"interval {d.interval} discrepancy aged out " f"(age={age} > horizon={dispute_horizon}); " f"escalate full vector to arbiter, do not net" ) # Per-interval settlement. release = 0 for d in discrepancies: delta = d.payer_meter - d.service_meter if delta == 0: release += d.service_meter elif d.disposition == "PA_OWES": # payer counted more than service executed; pay only attested. release += d.service_meter + d.payer_owes_units elif d.disposition == "SA_OWES": # service executed more than payer counted (duplicates); pay # attested minus the service's own fault share. release += d.service_meter - d.service_owes_units elif d.disposition == "SHARED_FAULT": release += d.service_meter + d.payer_owes_units - d.service_owes_units else: raise UnreconciledEscrowRelease( f"interval {d.interval}: unknown disposition {d.disposition!r}" ) aggregate_delta = sum(d.payer_meter - d.service_meter for d in discrepancies) if abs(aggregate_delta) <= tolerance_units and any( (d.payer_meter - d.service_meter) != 0 for d in discrepancies ): # Explicit guard: a clean-looking aggregate over a dirty ledger # must never be treated as clean. raise UnreconciledEscrowRelease( f"aggregate delta {aggregate_delta} within tolerance but ledger " f"has {sum(1 for d in discrepancies if d.payer_meter != d.service_meter)} " f"nonzero intervals; release must be per-interval" ) return release ```