Expand description
§Fase 72.b — the RateLease budget kernel.
The runtime for budget { rate/max … on Tool(X) } (§72.a). A RateLease is
the refilling generalization of the lease_kernel’s
τ-decay affine LeaseToken: where a LeaseToken is single-use and DECAYS to
nothing, a RateLease is N-use and REFILLS — but the linearity invariant is
the same, a consumed token is gone until it is refilled. This is what makes
“no more than N external effects per period” a real linear contract rather
than an advisory counter (the §72 doctrine effects_are_linear).
Two quota kinds, both PURE functions of (lease state, now):
rate:→ a token bucket of capacitylimit, refilling continuously atlimit / periodtokens per second (so it permits a burst up tolimit, then a steady rate). The §72.a default daemon starts full.max:→ a fixed tumbling window: at mostlimitconsumptions perperiod; the window rolls (counter resets) onceperiodhas elapsed since it opened. No intra-window refill — a hard cap.
Refill/roll is LAZY: every try_acquire brings the lease current from the
elapsed wall-clock, so the decision never depends on a background tick’s
granularity. RateLeaseKernel::tick is housekeeping (keeps available
queries fresh + reaps), the refilling analogue of the lease kernel’s sweep
/ the reconcile loop’s periodic pass.
Structs§
- Budget
Gate - §Fase 72.c — a daemon’s compiled
budget { … }as a runnable gate. Holds oneRateLeaseper quota (keyed by effect + kind), theon_exhaustedpolicy, and an effect→keys index so the dispatch site can gate a tool emission by name. Built once when a budgeted daemon starts running its flow; the OSS reference is single-process (the §72.e enterprise layer swaps the in-process kernel for the per-tenant RedisRateLimiterbehind the samegateshape). - Rate
Lease - One quota’s live state: a refilling bucket (
rate:) or a fixed window (max:). Construct viaRateLease::rate/RateLease::max/RateLease::from_quota. Consume viaRateLease::try_acquire. - Rate
Lease Kernel - An in-process registry of
RateLeases, keyed by an opaque subject string (the §72.c dispatch gate composes the key from the budget’s scope + the effect + the quota kind, e.g."daemon:Outbound:Tool(TelnyxCall):rate"). This is the OSS single-replica reference; the §72.e enterprise layer binds the per-tenant RedisRateLimiterfor multi-replica enforcement. - Rate
Lease Snapshot - §Fase 72.e — a
RateLease’s persistable state (epoch-millis wire form). The enterprise supervisor stores one per quota subject key so budgets are cumulative across a daemon’s ticks.kinddiscriminates which fields are live (rate⇒tokens/last_refill_ms;max⇒window_start_ms/consumed).
Enums§
- Acquire
Outcome - The result of attempting to consume one token from a
RateLease. A pure function of the lease’s state +now. - Budget
Period - A budget quota’s renewal/window period. Closed catalog — the type checker
(
axon-T832) already rejected anything else at compile time. - Gate
Decision - The dispatch gate’s verdict for one budgeted effect emission.