mirror of
https://github.com/bitbaum/ai-kit.git
synced 2026-12-04 04:47:42 +01:00
Across this fleet the same feature exists twice, half each. One app enforces a daily AI budget with no interface at all: the user is refused, and never learns why or what their share was. Another draws a quota meter with its own separate notion of tier, which the enforcement path does not read. Both are correct in isolation and they cannot agree, because there was no single statement of the policy for them to agree ABOUT. `decide(policy, state)` is that statement. The gate asks it whether to allow; the settings page asks it what to draw. A number on screen the gate does not use is decoration, and a gate whose reasoning cannot be rendered is a wall. Pure, by the same rule as fair-share: no database, no clock, no provider. WHY A REFUSAL CARRIES A LADDER Shared free capacity is a fixed cost carried on behalf of strangers, and its only job is to be good enough, once, that someone wants more of it. The moment it runs out is the only moment anybody changes anything — which makes the refusal the most important screen in the product, not an error state. So `decide` returns a `Wall`, not a boolean. The default order offers the exits that cost the user NOTHING before the one that costs money: asking someone to make a free account elsewhere converts better than asking them to pay, and it takes them off the shared pool just as completely. FOUR PROPERTIES WORTH THE TESTS THEY COST - `wait` is always the floor, and a config cannot remove it. A refusal with no way forward reads as a broken product; "it refills at 01:00" is a path. - An unknown tier fails CLOSED. A typo in a config should cost nothing, not hand out the shared pool. - Uncapped is `null`, never 0. Rendering null as a gauge at zero would tell a user on their own key that they are out — the opposite of true. - A rung the user cannot take is marked unavailable rather than dropped. Dropping it makes the list differ per user for reasons nobody can see. `shouldSurface()` keeps the indicator quiet until it matters: a permanent gauge at 96% trains people to ignore the one at 4%. 190 tests, up from 179. Claude-Session: https://claude.ai/code/session_01CAfKwM1oUSA9tU9fgdhfdf Co-authored-by: Cato <georgy.butaev@revamp-it.ch> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>