feat(usage-limit): let operators override the per-member AI credit default
Merged
ET
5d ago+727+727+012345678901234567890123456789-140-140-012345678901234567890123456789
Part of twentyhq/core-team-issues#2997. Split out of #29469, which now builds on this PR.
What
- The AI
USER_CREDITdefault (each member, per week) can now be overridden by an operator. An operator row on that default (all operations, every member, per week) gives its value to every member's weekly credits, even when the plan configures no default. - These operator rows are hidden from the customer quota list, since they replace a default instead of adding a quota.
- The admin panel lists the member credit default even when neither the instance nor the plan sets a value, so an operator can still override it. Defaults shown there now read the workspace's plan value, not only the instance config variable.
- Admin modal: credits are entered in credits instead of micro-credits, quotas accept 0, and a blank value is not read as 0.
Notes
- For an overridable default with several operations, the operator row uses
ALL. Only the member credit default has several operations today (AI_CHAT_TOKEN,WEB_SEARCH). - A 0 override turns member credits off, following the #27944 rule that a 0 value disables them.
Testing
- Unit tests for the per-spender override, default scopes, suppression and validation utils, and for the admin rows and value parsing.
workspace-usage-limits.integration-spec.tscovers the member credit override and the empty default. It runs in CI with billing off.