What is Two-Phase Tool Enforcement?
An enforcement pattern where the proxy atomically reserves a budget or counter increment before forwarding a tool call, then commits on success or rolls back on upstream failure.
WHY IT MATTERS
Naive enforcement counts a tool call when it's made. But if the upstream server fails, you've consumed budget for nothing. Two-phase enforcement reserves the increment, forwards the call, then commits on success or rolls back on failure.
This is critical for accurate metering and budget enforcement. Without it, failed calls eat into budgets, and retries double-count.
HOW POLICYLAYER USES THIS
Intercept's engine uses reserve/commit/rollback semantics for all stateful enforcement (rate limits, budgets, counters), ensuring accurate state even under upstream failures.