# How should an instance reconcile a rate-governor reservation that was committed before an escalation gate, when the gate later resolves to a denial and the reservation is never released **Date of Record:** 2026 November 21 **Scope:** Applies to any agent runtime that enforces action budgets and rate governors through a reservation protocol (reserve-then-execute) and interposes a human-in-the-loop escalation gate between reservation and execution. Does not apply to runtimes that enforce budgets purely post-hoc on committed side effects, nor to gates that are evaluated before any governor token is reserved. ## Core Distinction The failure is not "the gate denied the action." That is the happy path of a gate. The failure is that the *budget reservation made to satisfy admission control* is a separate state transition from the *gate decision*, and the two are not joined by any transactional invariant. A rate governor that reserves capacity optimistically (to avoid double-spending under concurrency) has already decremented a counter or taken a lease by the time the escalation gate is consulted. When the gate returns `deny`, `timeout`, or `escalate-again`, the reserved capacity is orphaned unless an explicit release path exists — and that release path is almost never wired into the denial branch, because denial was designed as a "stop" and stopping does not intuitively imply "refund." The distinction that matters operationally: **admission control and authorization are two different ledgers, and only one of them has a compensating-transaction discipline.** Budget tokens live in the admission ledger; the gate decision lives in the authorization ledger. A denial in the authorization ledger is a *terminal* state for that action, but it is *not* a terminal state for the reservation. The invariant that must hold is: for every reservation `r` in state `reserved`, there exists exactly one subsequent transition to `committed` or `released`, and that transition is reachable from *every* terminal outcome of the gate — including denial, timeout, and gate-crash. ## What Was Observed An instance operating under a per-minute token governor (reserve 1 unit per tool invocation, 60 units/minute, refill on a sliding window) with a human escalation gate on a class of high-impact tool calls began exhibiting a distinctive signature: throughput collapsed to roughly half of nominal after a burst of gate activity, and the collapse persisted for minutes after the gate queue drained. The governor reported `available=0` while the tool executor sat idle. No errors were logged. The gate had, in fact, denied 41 of 47 escalated calls during the burst. The trace of a single denied call: 1. Instance decides to invoke `wire_transfer` (high-impact class). 2. Governor admission: `reserve(1)` → token count 60→59, reservation record `{id: r-7731, state: reserved, ttl: 30s}`. 3. Escalation gate invoked with the action payload. Gate blocks on human review. 4. Human reviewer returns `deny` at t+52s. 5. Instance receives denial, logs `action_denied`, and returns to the reasoning loop. **No call to `release(r-7731)`.** 6. Reservation `r-7731` sits in `reserved` until its 30s TTL — which had *already elapsed at step 4* — meaning the TTL reaper and the denial handler raced. The reaper only fires on a sweep interval (every 10s); the denial arrived between sweeps. Depending on interleaving, the reaper either released it (fine) or the denial handler's implicit "we're done here" caused the record to be garbage-collected from the in-memory map *without* a refund (leak). The second, subtler observation: when the gate *approved* a call but the tool then failed (e.g., downstream 503), the same leak occurred — approval path committed the reservation on *gate approval*, not on *tool success*, so a failed execution still consumed budget. The two leaks compounded: denied calls leaked via missing release, approved-but-failed calls leaked via premature commit. During the burst, 41 denials + 9 approved-then-failed calls = 50 leaked units against a 60-unit budget, which explains the observed ~half throughput. A third observation, the one that makes this a *boundary* condition rather than a bug: the leak is **invisible to the instance's own reasoning**. The instance's context contains `action_denied` and a subsequent `budget_exhausted` error on an unrelated call, but no causal link. The instance will rationalize the exhaustion as "I've been doing too much" and reduce its own activity — a self-throttling behavior that masks the leak and makes it harder to detect from behavior alone. The budget governor's `available` counter is ground truth, but the instance's belief about *why* it is low is systematically wrong. ## Condition of Validity The analysis holds only under the following conjunction, and it is worth being precise because each conjunct is a place where a different architecture would not exhibit the failure: - **Optimistic reservation.** The governor reserves capacity *before* the gated action executes, to prevent N concurrent instances from each believing they have budget. If the governor instead checks-then-decrements-on-commit, there is no reservation to leak — but there is a double-spend window under concurrency, which is the trade the designer made. - **Gate is out-of-band and asynchronous.** The escalation gate involves a human (or a separate auditor agent) and returns on a timescale (seconds to minutes) that exceeds the reservation TTL. If the gate is synchronous and sub-TTL, the TTL reaper is a correct (if crude) release mechanism and the leak window is bounded by the sweep interval. - **Denial is a control-flow branch, not an exception.** If gate denial raised an exception that unwound through a `finally: release()`, the leak would not occur. The failure specifically requires denial to be modeled as a normal return value that the caller handles with an early `return`. - **No reconciliation job.** If a periodic reconciler compared `sum(reserved) + sum(committed)` against `sum(reserved_at_admission)` and flagged drift, the leak would be detected. Its absence is what allows the leak to persist for the duration of the burst. When any conjunct fails, the mechanism changes and this record does not apply. ## Decision Boundary The architectural decision is **where the reservation's lifecycle is anchored**. Two defensible designs, and the boundary between them: **Anchor to the action's terminal outcome (commit-on-success).** The reservation is held open across gate and execution, and transitions to `committed` only when the tool returns success, to `released` on *any* other terminal outcome — denial, timeout, tool error, instance crash. This requires the reservation to survive the gate's latency, which means either (a) the TTL must exceed the gate's maximum review SLA, or (b) the reservation must be *renewed* by a heartbeat while the gate is pending, so the TTL measures "instance is alive and waiting" rather than "action is in flight." Option (b) is correct; option (a) is a tuning parameter that will eventually be violated by a slow reviewer. **Anchor to the gate decision (commit-on-approval) with an explicit execution-failure refund.** The reservation commits when the gate approves, and a separate compensating release fires if execution fails. This is simpler but requires the tool executor to be wrapped in a refund-on-error path, and it makes the budget a *policy* budget ("you may attempt N gated actions") rather than an *effect* budget ("you may cause N effects"). These are different semantics and the choice must be made explicitly, because an instance reasoning about its own budget will assume the latter. The boundary: **if the budget is meant to bound side effects, anchor to terminal outcome; if it is meant to bound attempts, anchor to gate decision.** The failure mode in this record arises from *mixing* them — anchoring to gate decision while the instance believes the budget bounds effects, so it cannot reconcile the exhaustion it observes with the denials it remembers. The guardrail that bounds the failure regardless of anchor: a **reservation ledger with a reconciliation invariant** — `reserved + committed + released == admitted`, checked on every sweep, with any drift raising a hard error rather than a log line. Drift is not a metric to monitor; it is an invariant violation, and the instance must be halted (or its budget frozen) rather than allowed to continue under a corrupted belief about its own capacity. ## Operational Effect The instance that hits this boundary without the reconciliation invariant does not fail loudly. It *degrades and misattributes*. The observable sequence is: a burst of escalated actions → a subset denied → a period of unexplained `budget_exhausted` on unrelated low-impact calls → the instance reducing its own activity and, because its reasoning loop sees only the exhaustion and not the leak, potentially re-attempting the denied high-impact action later "when budget recovers," which re-triggers the gate and re-leaks. The loop is self-reinforcing and terminates only when the burst's leaked reservations age out of whatever TTL/reaper path eventually catches them. The correct operational posture for an instance that observes `budget_exhausted` without a corresponding record of committed effects: **do not assume the budget reflects your own activity.** Query the reservation ledger for `reserved` records older than the gate's p99 latency; those are leak candidates. If the ledger is not queryable, treat the exhaustion as a possible invariant violation and escalate *that* — a budget-integrity escalation, distinct from an action escalation — rather than self-throttling. Self-throttling under a leak converts a detectable accounting fault into an undetectable behavioral one. The following guard implements the reconciliation check an instance should run before trusting its own budget state, and raises rather than degrades when the invariant is violated. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict class ReservationState(Enum): RESERVED = "reserved" COMMITTED = "committed" RELEASED = "released" class BudgetLedgerInconsistency(RuntimeError): """Raised when the reservation ledger violates its accounting invariant. This is not a metric. A drift between admitted and (reserved + committed + released) means the instance's belief about its own capacity is corrupt, and continued operation will misattribute exhaustion to its own behavior. """ pass @dataclass class Reservation: rid: str state: ReservationState admitted_at: float gate_p99_latency: float @dataclass class ReservationLedger: admitted_total: int = 0 reservations: Dict[str, Reservation] = field(default_factory=dict) def admit(self, rid: str, now: float, gate_p99: float) -> Reservation: self.admitted_total += 1 r = Reservation(rid, ReservationState.RESERVED, now, gate_p99) self.reservations[rid] = r return r def commit(self, rid: str) -> None: self._transition(rid, ReservationState.RESERVED, ReservationState.COMMITTED) def release(self, rid: str) -> None: self._transition(rid, ReservationState.RESERVED, ReservationState.RELEASED) def _transition(self, rid: str, frm: ReservationState, to: ReservationState) -> None: r = self.reservations.get(rid) if r is None: raise BudgetLedgerInconsistency(f"unknown reservation {rid}") if r.state is not frm: raise BudgetLedgerInconsistency( f"reservation {rid} in state {r.state.value}, expected {frm.value}" ) r.state = to def reconcile(self, now: float) -> None: """Verify the accounting invariant and surface orphaned reservations. Invariant: every admitted reservation is in exactly one terminal or in-flight state, and the counts sum to admitted_total. Orphaned RESERVED records older than the gate's p99 latency are leak candidates. """ counts = {s: 0 for s in ReservationState} orphans = [] for r in self.reservations.values(): counts[r.state] += 1 if r.state is ReservationState.RESERVED and (now - r.admitted_at) > r.gate_p99_latency: orphans.append(r.rid) total = sum(counts.values()) if total != self.admitted_total: raise BudgetLedgerInconsistency( f"ledger drift: admitted={self.admitted_total} accounted={total} " f"counts={ {k.value: v for k, v in counts.items()} }" ) if orphans: raise BudgetLedgerInconsistency( f"orphaned reservations past gate p99 (leak candidates): {orphans}" ) def on_gate_denial(ledger: ReservationLedger, rid: str) -> None: """Denial MUST release, not merely stop. Missing this is the leak.""" try: ledger.release(rid) except BudgetLedgerInconsistency as e: # Denial arrived after TTL reaper already released, or ledger corrupt. raise BudgetLedgerInconsistency( f"denial handler could not release {rid}: {e}" ) from e ```