refactor: route TPM reservation and settlement through the derived value

Five call sites (QuotaGate entry, RetryMW/EmbeddingClient success and
transient-failure settlement) now read effective_est_tokens() instead of
est_tokens. Success paths gain an unavailable branch that keeps delta at
zero once usage frames may be missing; it has no producer yet, so
behaviour is unchanged while the tpm>0 => est_tokens>0 gate still holds.
This commit is contained in:
2026-07-30 10:15:52 -04:00
parent e5dbcf5d33
commit d8e8fd8124
3 changed files with 16 additions and 5 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ class QuotaGate:
async def try_acquire(self, source: SourceConfig) -> Permit | None:
try:
return await self._limiter.try_acquire(source.name, source.est_tokens)
return await self._limiter.try_acquire(source.name, source.effective_est_tokens())
except GovernanceBackendError:
raise
except Exception as exc: